设为首页
加入收藏
站内地图
旧版入口

右键菜单的制作!

作者:佚名 出处:网络转载 时间:07-26 点击:

内容载入中...



 MENU.JS// 菜单的HTML代码

 var strMenu = "  onMouseover=\"highlight()\" onMouseout=\"lowlight()\">"

 strMenu += " 刷新"

 strMenu += " 关闭"

 strMenu += "


"

 strMenu += " http://fj126.net);\"
 >设为首页"

 strMenu += "  .::蓝雨设计网::.)\">加入收藏"

strMenu += "

"

// 判断客户端浏览器

 function ie() {

 if (navigator.appName=="Microsoft Internet Explorer") {

 return true;

 } else {

 return false;

 }}

// 显示菜单

 function showmenu(){

 if (ie()){

 // 找出鼠标在窗口中的位置

 var rightedge=document.body.clientWidth-event.clientX

 var bottomedge=document.body.clientHeight-event.clientY


// 如果横向的距离小于菜单的宽度

 if (rightedge
 // 将菜单向左移动到适当的位置

 menu.style.left=document.body.scrollLeft+event.clientX-menu.offsetWidth

 else

 // 否则,就在该位置显示菜单

 menu.style.left=document.body.scrollLeft+event.clientX


// 与上面道理相同,判断纵向的位置

 if (bottomedge
 menu.style.top=document.body.scrollTop+event.clientY-menu.offsetHeight

 else

 menu.style.top=document.body.scrollTop+event.clientY


menu.style.visibility="visible"

 }

 return false

 }




 // 隐藏菜单

 function hidemenu(){

 if (ie()) menu.style.visibility="hidden"

 }

// 菜单项获得焦点时加亮显示

 function highlight(){

 if (event.srcElement.className=="menuitems"){

 event.srcElement.style.backgroundColor="highlight"

 event.srcElement.style.color="highlighttext"

 }}

// 菜单项失去焦点

 function lowlight(){

 if (event.srcElement.className=="menuitems"){

 event.srcElement.style.backgroundColor=""

 event.srcElement.style.color="menutext"

 }}

if (ie()) document.write (strMenu);

 document.oncontextmenu= showmenu

 document.body.onclick= hidemenu

 MENU.CSS

 .clsMenu {

 cursor: default;

 color: menutext;

 position: absolute;

 width: 120px;

 background-color: menu;

 border: 1 solid buttonface;

 visibility:hidden;

 border: 2 outset buttonhighlight;

 }


.menuitems{

 font-size: 12px;

 color: #000000;

 padding-left:20px;

 padding-right:10px;

 line-height: 20px

 }

 INDEX.HTM把加入HEAD区

 把 加入BODY区

收藏本文:
】【打印页面】【推荐给朋友】【关闭窗口
推荐信息