IE NC Universal right mouse button method

Source: Internet
Author: User
Mouse | Right button

First of all, for Internet Explorer to hide the right mouse button method, it can be said that as long as the person who has done the Web page may know to use Document.oncontextmenu=function ("return false;"); For Netscape, however, this approach is not entirely possible. Through practice, I found that in Internet Explorer and Netscape two browsers have some elements, the right mouse button click on the top is no response. Now I'm using this to hide the right mouse button. We can know that in the Internet Explorer and Netscape two browser <div> in the scroll bar is not able to play the right button menu, then we in the right key event to our custom <div> element Just_hide_ It moves to the point where the mouse clicks, so it's not possible to pop up the right button menu.

The source code is as follows:

<!--
Edited by Renjian Zhou (Joo), Shanghai Jiao and Tong university,application Mathematic,class. If you are are interested in editing HTML pages,connected me bybombjet.joo@163.com.
-->
<title>
Universal Hidden right mouse button
</title>
<body style= "Z-INDEX:-1;" >
<script language= "JavaScript" >
Tmp=navigator.appversion.tostring ();
Ie=parsefloat (Tmp.substring (Tmp.indexof ("MSIE") +4,tmp.length));
function Nc_rightclick (e)
{
if (e.button==2 | | (e.button==0 && e.type== "ContextMenu"))
{
document.getElementById (' Just_hide_it '). style.left=e.clientx-14;
document.getElementById (' Just_hide_it '). style.top=e.clienty-14;
return false;
}
}
if (IE)
Document.oncontextmenu=function ("return false;");
Else
{
document.write (' <div id= ' just_hide_it "style=" z-index:-1;position:absolute;left:100;top:0;overflow:scroll; width:28;height:28; " ></div> ');
Document.oncontextmenu=nc_rightclick;
Document.onmousedown=nc_rightclick;
}
</script>
</body>


Explain: The <div> method is also effective in Internet Explorer, not only in Netscape, but in Internet Explorer, but now that there are more efficient ways to do this, I wouldn't have to do it that way. In Netscape to just_hide_it requirements Z-index-1 and body z-index the same is out of making just_hide_it transparent, people do not feel that there is such an element exists.

Again, we hide the right mouse button for the purpose of not hiding the source code, but for some other Web page features. By the way, I encourage you prawns, there are good code, more sharing. After all, the world should be a shared world.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.