JS禁止WEB頁面鼠標事件大全


<!--禁止鼠標右鍵代碼-->;<noscript><ifra;<scriptlanguage=javas;<!--;if(window.Event);document.captureEvents(E;functionnocontextmenu(){;event.cancelBubble=true;event.ret

 

<!--禁止鼠標右鍵代碼-->

<noscript><iframe src=*.html></iframe></noscript>

<script language=javascript>

<!--

if (window.Event)

document.captureEvents(Event.MOUSEUP);

function nocontextmenu(){

event.cancelBubble = true

event.returnValue = false;

return false;

}

function norightclick(e){

if (window.Event){

if (e.which == 2 || e.which == 3)

return false;

}

else

if (event.button == 2 || event.button == 3){

event.cancelBubble = true

event.returnValue = false;

return false;

}

}

document.oncontextmenu = nocontextmenu; // for IE5+

document.onmousedown = norightclick; // for all others

//-->

</script>

 

1.將徹底屏蔽鼠標右鍵,無右鍵菜單

<body oncontextmenu="window.event.returnvalue=false">

 

也可以用於網頁中Table框架中

<table border oncontextmenu=return(false)><td>no</table>

 

2.取消選取、防止復制

<body onselectstart="return false">

 

3.不准粘貼

<body onpaste="return false">

 

4.防止復制

<body oncopy="return false;" oncut="return false;">

 

5.IE地址欄前換成自己的圖標

<link rel="Shortcut Icon" href="favicon.ico">

 

說明:關於favicon.ico文件的制作。你可以先在FW中做一個圖片,屬於你自

己站點一個小圖標。然后在ACD see將文件屬性改為*.ico,然后將你做的*.ICO

文件傳到你的服務器目錄中,然后就可以使用以上代碼來實現,當別人登陸你的

站點時,地址欄里使用 的就是你自定義的圖標了。很PP哦。

 

6.可以在收藏夾中顯示出你的圖標

在網頁的〈head〉〈/head〉間加入以下語句:

〈link rel="shortcuticon" href="http://…/icon.ico"〉

 

即可。其中 icon.ico 為 16x16 的圖標文件,

顏色不要超過 16 色。

 

說明:制作方法和上面的一樣。只是顯示的方式不同,這個是在別人收藏你的網

頁地址時顯示的個性圖標。也很PP.

 

7.關閉輸入法

<input style="ime-mode:disabled">

 

說明:這段代碼是在表格提交時用到的。也就是在輸入數據時不可以使用其他輸

入法模式。

 

網頁經典代碼(二)

 

8.永遠都會帶着框架

 

<script language="javascript"><!--

if (window == top)top.location.href = "frames.htm";// --></script>

 

說明:frames.htm為你的網頁,這也是保護頁面的一種方法

 

9.防止被人frame

 

<SCRIPT LANGUAGE=javascript><!--

if (top.location != self.location)top.location=self.location;

// --></SCRIPT>

 

10.網頁將不能被另存為

 

<noscript><iframe src=*.html></iframe></noscript>

說明:<noscirpt>的用法很廣,其中一條就是可以使JS廣告失效。

 

11.查源文件

 

<input type=button value=查看網頁源代碼

onclick="window.location = 'view-source:'+

'http://www.e3i5.com/test.htm';">

 

12.COOKIE腳本記錄,有很大的用處哦

 

function get_cookie(Name) {

var search = Name + "="

 

var returnvalue = "";

 

if (documents.cookie.length > 0) {

 

offset = documents.cookie.indexOf(search)

 

if (offset != -1) { // if cookie exists

 

offset += search.length

 

// set index of beginning of value

 

end = documents.cookie.indexOf(";", offset);

 

// set index of end of cookie value

 

if (end == -1)

 

end = documents.cookie.length;

 

returnvalue=unescape(documents.cookie.substring(offset, end))

 

}

 

}

 

return returnvalue;

 

}

 

 

function loadpopup(){

 

if (get_cookie('popped')==''){

 

openpopup()

 

documents.cookie="popped=yes"

 

}

 

}

 

說明:以上是JS代碼,請自己加起始符和結束符

<SCRIPT LANGUAGE=javascript>

function click() {

alert('禁止你的左鍵復制!') }

function click1() {

if (event.button==2) {alert('禁止右鍵點擊~!') }}

function CtrlKeyDown(){

if (event.ctrlKey) {alert('不當的拷貝將損害您的系統!') }}

document.onkeydown=CtrlKeyDown;

document.onselectstart=click;

document.onmousedown=click1;

</SCRIPT>

 

<noscript>

<iframe src="*.htm"></iframe>

</noscript><SCRIPT language=javascript>

<!--

if (window.Event)

document.captureEvents(Event.MOUSEUP);

function nocontextmenu(){

event.cancelBubble = true

event.returnValue = false;

return false;

}

function norightclick(e){

if (window.Event){

if (e.which == 2 || e.which == 3)

return false;

}

else

if (event.button == 2 || event.button == 3){

event.cancelBubble = true

event.returnValue = false;

return false;

}

}

document.oncontextmenu = nocontextmenu; // for IE5+

document.onmousedown = norightclick; // for all others

//-->

</SCRIPT>

以上是禁止右鍵和另存為

 

3、讓頁面文字不被選中和復制

<body onselectstart="return false">

<body oncopy=alert(’對不起,禁止復制!’);event.returnvalue=false;>

 

除非你做的是框架式結構的網站 再加上 網頁將不能被另存為

<noscript><iframe src=*.html></iframe></noscript>

說明:<noscirpt>的用法很廣,其中一條就是可以使JS廣告失效。 <!--禁止鼠標右鍵代碼-->

<noscript><iframe src=*.html></iframe></noscript>

<script language=javascript>

<!--

if (window.Event)

document.captureEvents(Event.MOUSEUP);

function nocontextmenu(){

event.cancelBubble = true

event.returnValue = false;

return false;

}

function norightclick(e){

if (window.Event){

if (e.which == 2 || e.which == 3)

return false;

}

else

if (event.button == 2 || event.button == 3){

event.cancelBubble = true

event.returnValue = false;

return false;

}

}

 

 

document.oncontextmenu=n;document.onmousedown=nor;//-->;</script>;保證可以;1.利用彈出窗口封鎖鼠標右鍵;<scriptlanguage=";(event.button==2){alert(;^_^')}}document.onmo;2.徹底封鎖鼠標右鍵

 

document.oncontextmenu = nocontextmenu; // for IE5+

document.onmousedown = norightclick; // for all others

//-->

</script>

保證可以。

1.利用彈出窗口封鎖鼠標右鍵

<script language="javascript">function click() {if

(event.button==2) {alert('本站不准使用右鍵,使用左鍵吧!

^_^')}}document.onmousedown=click</script>

2.徹底封鎖鼠標右鍵

<script>

function

DM(e){if(!ns){if(event.button>1)window.external.addFavorite

('http://www.popunet.com/,' 大眾網絡報')}else{if(e.which>1)return false}}ns=navigator.appName=="Netscape";if(ns)document.captureEvents (Event.MOUSEMOVE|Event.MOUSEDOWN);document.onmousemove=DM;document. onmousedown=DM;</script>

3.禁止查看源文件

 

<script language="JavaScript">

<!--document.onmousedown=click function click() {

if ( event.button==2) {alert('不准查看源文件') }

if ( event.button==3) {alert('不准查看源文件') }}

//--></script>

其實這個想法根本就實現不了,你要是不想被人家復制,最好的辦法就是不放在網上,這些代碼都是些自欺欺人的方法,放棄這個念頭吧!

禁止查看源代碼[保護您的源代碼]

 

====1、將以下代碼加入到HEML的<body></body>之間

 

<SCRIPT language=javascript>

function click() {if (event.button==2) {alert('不許你偷看!

');}}document.onmousedown=click

</SCRIPT>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM