在这里我封装了一个阻止页面右键的函数,目前是初学,可能还不太完善:
<script>
function addEvent(obj,sEv,fn){
if(obj.addEventListener){
obj.addEventListener(sEv,fn,false);
}else{
attachEvent('on'+sEv,fn);
}
}
window.οnlοad=function(){
addEvent(document,'contextmenu',function(ev){
var oEvent=ev||event;
oEvent.preventDefault && oEvent.preventDefault();
return false;
})
}
</script>