您现在的位置是:首页 >

win7鼠标右键没反应 IENC通用的藏鼠标右键一法

火烧 2021-07-24 19:02:48 1046
IENC通用的藏鼠标右键一法   首先 对于I ter et Ex lorer的隐藏鼠标右键的方法 可以说只要弄过网页的人可能知道要用 docume t o co textme u=Fu ctio r
win7鼠标右键没反应 IENC通用的藏鼠标右键一法

IENC通用的藏鼠标右键一法  

  首先 对于Internet Explorer的隐藏鼠标右键的方法 可以说只要弄过网页的人可能知道要用 document oncontextmenu=Function( return false; ); 不过对于Netscape 这个办法就并不能完全行的通 通过实践 我发觉 在Internet Explorer和Netscape这两款浏览器中都存在某些元素 鼠标的右键在上边点击是没有反应 现在我就利用如此一点来隐藏鼠标右键 我们可以知道在Internet Explorer和Netscape这两款浏览器中<div>的滚动条上是弹不出右键菜单的 那我们就在右键事件中把我们定制的<div>元素just_hide_it移到鼠标的点击的位置来 这样就不可能弹出右键菜单了

  源代码如下

  <><head><meta equiv= Content Type content= text/; charset=gb ><! Edited by Renjian Zhou(Joo) Shanghai Jiao Tong University Application Mathematic Class F If you are interested in editing HTML pages connected me by ><title>通用的藏鼠标右键</title></head><body ><script language= JavaScript >tmp=navigator appVersion toString();IE=parseFloat(tmp substring(tmp indexOf( MSIE )+ tmp length));function NC_rightclick(e){if(e button== || (e button== && e type== contextmenu )){  document getElementById( just_hide_it ) style left=e clientX ;  document getElementById( just_hide_it ) style top=e clientY ;  return false;}}if(IE)document oncontextmenu=Function( return false; );else{document write( <div id= just_hide_it ></div> );document oncontextmenu=NC_rightclick;document onmousedown=NC_rightclick;}</script></body></>

  解释一下 不仅在Netscape中可以用如此<div>方法 在Internet Explorer中<div>方法也有效 不过既然在Internet Explorer中已经有了更有效的方法 我也就不用如此方法了 在Netscape中对just_hide_it要求z Index为 与body的z index相同是出于使just_hide_it透明化 使人感觉不出有如此一个元素的存在

lishixinzhi/Article/program/Java/JSP/201311/19547  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码