導航:首頁 > 編程語言 > js屏蔽滑鼠右鍵的代碼

js屏蔽滑鼠右鍵的代碼

發布時間:2025-10-03 05:36:44

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>

閱讀全文

與js屏蔽滑鼠右鍵的代碼相關的資料

熱點內容
網路中常用的傳輸介質 瀏覽:518
文件如何使用 瀏覽:322
同步推密碼找回 瀏覽:865
樂高怎麼才能用電腦編程序 瀏覽:65
本機qq文件為什麼找不到 瀏覽:264
安卓qq空間免升級 瀏覽:490
linux如何刪除模塊驅動程序 瀏覽:193
at89c51c程序 瀏覽:329
怎麼創建word大綱文件 瀏覽:622
裊裊朗誦文件生成器 瀏覽:626
1054件文件是多少gb 瀏覽:371
高州禁養區內能養豬多少頭的文件 瀏覽:927
win8ico文件 瀏覽:949
仁和數控怎麼編程 瀏覽:381
項目文件夾圖片 瀏覽:87
怎麼在東芝電視安裝app 瀏覽:954
plc顯示數字怎麼編程 瀏覽:439
如何辨別假網站 瀏覽:711
寬頻用別人的賬號密碼 瀏覽:556
新app如何佔有市場 瀏覽:42

友情鏈接