Maison >interface Web >js tutoriel >禁止IE用右键的JS代码_javascript技巧
document.body.oncontextmenu=function rightClick(){ window.event.returnValue= false;}
var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
<script> <BR>function stop(){ <BR>return false; <BR>} <BR>document.oncontextmenu=stop; <BR></script>