十二月 13 2006
防止網頁IE使用右鍵及反白,連 Firefox 都不行
防止使用右鍵,連 Firefox 都不行
<head>加在這邊</head>
< !-–防止使用右鍵,連 Firefox 都不行 start-–> <script type="text/javascript"> function clickIE4(){ if (event.button==2){ return false; }//end if }//end func function clickNS4(e){ if (document.layers||document.getElementById&&!document.all){ if (e.which==2||e.which==3){ return false; }//end if }//end if }//end func function OnDeny(){ if(event.ctrlKey || event.keyCode==78 && event.ctrlKey || event.altKey || event.altKey && event.keyCode==115){ return false; }//end if } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS4; document.onkeydown=OnDeny(); }else if (document.all&&!document.getElementById){ document.onmousedown=clickIE4; document.onkeydown=OnDeny(); }//end if document.oncontextmenu=new Function("return false"); </script> < !–-防止使用右鍵,連 Firefox 都不行 End-–>
防止反白,連 Firefox 都不行
<style><!-- body { -moz-user-select:none; } --></style>
增加上面的css樣式然後再加上下面body屬性
<body onselectstart="return false">
這樣即可
12 篇回應


請問這個語法要放在哪裡呀?
ie的右鍵是鎖起來了…
但是firefox還是能開右鍵捏…
直接放在<body>之前即可
我這邊測試是IE跟FF都不能開右鍵的
請確認您放的位置跟語法是正確的
放在 /head 之前
根本沒有用,是否請站長測試看看或是檢查語法那裡出錯
測試環境 ie8 & firefox3
C.K. 回應:
四月 9th, 2009 at 10:48:47
To:聰明人
我這邊測試IE跟FF都是正常封鎖右鍵
請再檢查一下您貼的語法是否跟本站的一樣
能夠加入禁止反白功能嗎
C.K. 回應:
五月 18th, 2009 at 11:42:38
在Body加入下面
<body ONDRAGSTART="window.event.returnValue=false" ONCONTEXTMENU="window.event.returnValue=false" onSelectStart="event.returnValue=false"></body>
IE Only
相當感謝格主~
解決了我長久以來的問題~
不知道您是否也能夠解決一下 FF 防反白的功能?
C.K. 回應:
十一月 30th, 2010 at 16:58:14
已經加入請看上面文章內容
你好:
在IE瀏覽器看都正常,但Firefox&Google瀏覽器產生反白現象,請問如何決解?
謝謝!
C.K. 回應:
一月 19th, 2011 at 16:28:27
您有加入下面
<style> <!-- body { -moz-user-select:none; } --> </style>到<head>這邊</head> 嗎
ie 解除javascript 就可以反白和複製了! (有加 一鍵解除)
請問要怎麼解決???
Firefox 則是 就算解除javascript 也不能反白和複製…
C.K. 回應:
三月 8th, 2011 at 17:57:05
只要解除javascript就可以使用右鍵了
這是無法解決的
只能將資料改成圖片了