⑴ javascript 怎樣屏蔽firefox的右鍵菜單
js">1種方式:
實現原理是,在<body>語法標簽里加入如下代碼:
ondragstart="window.event.returnValue=false;"oncontextmenu="window.event.returnValue=false;"onselectstart="event.returnValue=false;"
這里,滑鼠拖曳(ondragstart)、選擇(onselectstart)和右鍵彈出pop菜單。
2種方式:
在引用js文件中加入
document.oncontextmenu=function(){
returnfalse;
};
document.ondragstart=function(){
returnfalse;
};
document.onselectstart=function(){
returnfalse;};
document.onbefore=function(){
returnfalse;};
document.onselect=function(){
document.selection.empty();
};
document.on=function(){
document.selection.empty();
};
document.onmouseup=function(){
document.selection.empty();
};
3.屏蔽F5鍵刷新
<script>
functionDisableF5(){
with(event){
//F5andCtrl+R
if(keyCode==116||(ctrlKey&&keyCode==82)){
event.keyCode=0;
event.cancelBubble=true;
returnfalse;
}
}
}
document.onkeydown=DisableF5;
</script>