網頁,禁止滑鼠的各種事件

回覆文章
tony
文章: 585
註冊時間: 2012-02-26, 07:04
聯繫:

網頁,禁止滑鼠的各種事件

未閱讀文章 tony »

相關code可以自行參考。

一、加入css

代碼: 選擇全部

<style type="text/css">
body {
-moz-user-select : none;
-webkit-user-select: none;
}
</style>
二、加入js

代碼: 選擇全部

<script type="text/javascript">
function iEsc(){ return false; }
function iRec(){ return true; }
function DisableKeys() {
if(event.ctrlKey || event.shiftKey || event.altKey) {
window.event.returnValue=false;
iEsc();}
}
document.ondragstart=iEsc;
document.onkeydown=DisableKeys;
document.oncontextmenu=iEsc;
if (typeof document.onselectstart !="undefined")
document.onselectstart=iEsc;
else{
document.onmousedown=iEsc;
document.onmouseup=iRec;
}
function DisableRightClick(qsyzDOTnet){
if (window.Event){
if (qsyzDOTnet.which == 2 || qsyzDOTnet.which == 3)
iEsc();}
else
if (event.button == 2 || event.button == 3){
event.cancelBubble = true
event.returnValue = false;
iEsc();}
}
</script>
回覆文章

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客