導航:首頁 > 編程語言 > 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屏蔽滑鼠右鍵的代碼相關的資料

熱點內容
簡單概括資料庫原理 瀏覽:517
質檢部有哪些文件 瀏覽:112
pbb文件列印 瀏覽:438
dedecms伺服器安裝教程 瀏覽:118
安卓鎖屏破解工具apk 瀏覽:247
qq女生頭像韓系全身 瀏覽:830
手機qq2012java版 瀏覽:501
手機上怎麼把電影字幕文件 瀏覽:559
微信群里文件最大限量多少 瀏覽:134
js屏蔽滑鼠右鍵的代碼 瀏覽:660
301醫院app 瀏覽:337
java註解大全 瀏覽:531
怎麼刪除注冊表裡的數據 瀏覽:482
黑莓安裝版本區別 瀏覽:180
java中double類型相加 瀏覽:29
手機傳文件電視 瀏覽:205
nodejs中間層 瀏覽:237
如何解決網路的信號問題 瀏覽:490
es文件瀏覽器本地視頻 瀏覽:354
vba打開指定文件夾 瀏覽:815

友情鏈接