Method One: Take advantage of the mouse button's key value
<Scriptlanguage= "JavaScript"> functionBlockright (oevent) {varOdiv=document.getElementById ("Display"); if(window.event) oevent=window.event;//handling compatibility, getting event objects if(Oevent.button== 2) Alert ("cannot be used"); } window.onload= function() {Document.onmousedown=Blockright; } </Script> <Div> <textarearows= "4"cols= " the"ID= "Textin"> </textarea> <PID= "Display"></P> </Div>
Method Two: the mouse ContextMenu
(This requires the return attribute of IE and the Dom D Prevevrdefault () method)
<Scriptlanguage= "JavaScript"> functionBlockright (oevent) {if(window.event) {oevent=window.event;//handling compatibility, getting event objectsOevent.returnvalue= false; }ElseOevent.preventdefault (); } window.onload= function() {Document.oncontextmenu=Blockright; } </Script>
The ContextMenu event is often used when customizing the right-click content, that is, when the right-click content is masked = after customizing a div display menu.
JavaScript masks Two methods of the right mouse button.