资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
js 右键菜单,支持不同对象不同菜单(兼容IE、Firefox)
里面的代码修改也比较简单。
<html> <head> <title>ddd</title> <style> .DreamMenu { position:absolute; visibility:hidden; z-index:100; overflow:hidden; width:150px; background-color:buttonface; border:dimgray 1px solid !important; border:buttonhighlight menu menu buttonhighlight 2px outset; padding:1px !important; padding:1px 1px 1px 0px; font-size:12px; } .DreamMenu ul { margin:1px; border-bottom:buttonhighlight 1px solid; border-top:buttonshadow 1px solid; } .DreamMenu a { display:block; width:100%; padding:1px 2px 2px 20px; cursor:default; text-decoration:none; color:#000000; } .DreamMenu a:hover { background:highlight; color:#ffffff; } </style> </head> <body menu='menu'> <!---这段js最好写进文件方便用,为了在51能运行就直接写进来了---> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%3E%20%0D%0A%2F***%20%0D%0ADreamCore%20-%20JsLib%2FMenu%20%0D%0ADate%20%3A%20Dec%2003%2C%202006%20%0D%0ACopyright%3A%20DreamSoft%20Co.%2CLtd.%20%0D%0AMail%20%3A%20Dream%40Dreamsoft.Ca%20%0D%0AAuthor%20%3A%20Egmax%20%0D%0ABrowser%20%3A%20IE5.0%26%2B%2CFirefox1.5%26%2B%2CNetscape7.0%26%2B%20%0D%0AUpdate%3A%20%0D%0A***%2F%20%0D%0Aif(!document.all)%20document.captureEvents(Event.MOUSEDOWN)%3B%20%0D%0Avar%20_Tmenu%20%3D%200%3B%20%0D%0Avar%20_Amenu%20%3D%200%3B%20%0D%0Avar%20_Type%20%3D%20'A'%3B%20%0D%0Adocument.onclick%20%3D%20_Hidden%3B%20%0D%0Afunction%20_Hidden()%20%0D%0A%7B%20%0D%0Aif(_Tmenu%3D%3D0)%20return%3B%20%0D%0Adocument.getElementById(_Tmenu).style.visibility%3D'hidden'%3B%20%0D%0A_Tmenu%3D0%3B%20%0D%0A%7D%20%0D%0Adocument.oncontextmenu%20%3D%20function%20(e)%20%0D%0A%7B%20%0D%0A_Hidden()%3B%20%0D%0Avar%20_Obj%20%3D%20document.all%20%3F%20event.srcElement%20%3A%20e.target%3B%20%0D%0Aif(_Type.indexOf(_Obj.tagName)%20%3D%3D%20-1)%20return%3B%20%0D%0A_Amenu%20%3D%20_Obj.getAttribute('menu')%3B%20%0D%0Aif(_Amenu%20%3D%3D%20'null')%20return%3B%20%0D%0Aif(document.all)%20e%20%3D%20event%3B%20%0D%0A_ShowMenu(_Amenu%2C%20e)%3B%20%0D%0Areturn%20false%3B%20%0D%0A%7D%20%0D%0Afunction%20_ShowMenu(Eid%2C%20event)%20%0D%0A%7B%20%0D%0Avar%20_Menu%20%3D%20document.getElementById(Eid)%3B%20%0D%0Avar%20_Left%20%3D%20event.clientX%20%2B%20document.body.scrollLeft%3B%20%0D%0Avar%20_Top%20%3D%20event.clientY%20%2B%20document.body.scrollTop%3B%20%0D%0A_Menu.style.left%20%3D%20_Left.toString()%20%2B%20'px'%3B%20%0D%0A_Menu.style.top%20%3D%20_Top.toString()%20%2B%20'px'%3B%20%0D%0A_Menu.style.visibility%20%3D%20'visible'%3B%20%0D%0A_Tmenu%20%3D%20Eid%3B%20%0D%0A%7D%20%0D%0A%2F***%20%0D%0A%E5%8F%AF%E4%BB%A5%E6%94%AF%E6%8C%81%E5%85%B6%E4%BB%96%E6%A0%87%E7%AD%BEINPUT%2CIMG%20%0D%0A***%2F%20%0D%0A%3C%2Fscript%3E"> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%3E_Type%3D'INPUT%2CA%2CDIV%2CBODY%2CIMG'%3B%3C%2Fscript%3E"> <!-----设置一个菜单层----> <div id="menu" class='DreamMenu'> <a href='http://www.glzy8.com' _ewebeditor_ta_href="http%3A%2F%2Fwww.glzy8.com">管理资源吧</a> <a href='http://www.baidu.com' _ewebeditor_ta_href="http%3A%2F%2Fwww.baidu.com"> 百度</a> <a href='http://www.g.cn' _ewebeditor_ta_href="http%3A%2F%2Fwww.g.cn">google</a> <a href='http://tools.glzy8.com' _ewebeditor_ta_href="http%3A%2F%2Ftools.glzy8.com">站长工具</a> <ul></ul> <a href='4' _ewebeditor_ta_href="4">打印</a> </div> <!-----设置一个菜单层----> <div id="menu2" class='DreamMenu'> <a href='0' _ewebeditor_ta_href="0">哈哈</a> <a href='1' _ewebeditor_ta_href="1">我是个链接</a> <a href='2' _ewebeditor_ta_href="2">好开心啊</a> <a href='3' _ewebeditor_ta_href="3">查看</a> <ul></ul> <a href='4' _ewebeditor_ta_href="4">打印</a> </div> <!-----设置一个菜单层----> <div id="menu3" class='DreamMenu'> <a href='0' _ewebeditor_ta_href="0">哈哈</a> <a href='1' _ewebeditor_ta_href="1">我是图片</a> <a href='2' _ewebeditor_ta_href="2">虽然打不开</a> <a href='3' _ewebeditor_ta_href="3">查看</a> <ul></ul> <a href='4' _ewebeditor_ta_href="4">打印</a> </div> <table><tr><td height=100> <!-----设置一个菜单menu属性----> <a href='test.php' _ewebeditor_ta_href="test.php" menu='menu2'>菜单1</a> <a href='test.php' _ewebeditor_ta_href="test.php" menu='menu2'>菜单2</a> </td></tr></table> <div style='height:300;' menu='menu'></div> <img src='http://www.glzy8.com/images/logo.gif' _ewebeditor_ta_src="http%3A%2F%2Fwww.glzy8.com%2Fimages%2Flogo.gif" menu='menu3'>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程