html中禁止網(wǎng)頁另存為、復(fù)制、選取、查看源文件、屏蔽鼠標右鍵

admin HTML/CSS/JS評論1,141字數(shù) 766閱讀模式
摘要

在HTML網(wǎng)頁中加入幾行簡單的代碼可以禁止他人使用鼠標右鍵和“另存為”命令。

一、屏蔽鼠標右鍵

把網(wǎng)頁的標簽修改為下面的代碼

  1. <body oncontextmenu=self.event.returnValue=false onselectstart="return false">  

現(xiàn)在點擊鼠標右鍵就不會有任何反應(yīng)了。文章源自網(wǎng)吧系統(tǒng)維護-http://www.strong-digital.cn/7695.html

二、禁止“另存為”命令

在目標網(wǎng)頁末尾“”的標簽前面加上加入如下代碼,可以使“另存為”命令不能順利執(zhí)行。文章源自網(wǎng)吧系統(tǒng)維護-http://www.strong-digital.cn/7695.html

  1. <noscript>   
  2. <iframe scr="*.htm"></iframe>   
  3. </noscript>  

加入上述代碼后,當執(zhí)行“另存為”命令時,會彈出“保存網(wǎng)頁時出錯”的對話框。文章源自網(wǎng)吧系統(tǒng)維護-http://www.strong-digital.cn/7695.html

三、不用js也可以控制禁止右鍵!方法:

  1. <body oncontextmenu="return false"></body>   
  2.   
  3. <!-- 禁用右鍵: -->   
  4. <script>   
  5. function stop(){   
  6. return false;   
  7. }   
  8. document.oncontextmenu=stop;   
  9. </script>   
  10.   
  11. <body onselectstart="return false"> 取消選取、防止復(fù)制   
  12.   
  13. oncopy="return false;" oncut="return false;" 防止復(fù)制  

四:禁止查看源文件

  1. <html>   
  2. <head>   
  3. <script>   
  4. function clear(){   
  5. Source=document.body.firstChild.data;   
  6. document.open();   
  7. document.close();   
  8. document.title="看不到源代碼";   
  9. document.body.innerHTML=Source;   
  10. }</script>   
  11. </head>   
文章源自網(wǎng)吧系統(tǒng)維護-http://www.strong-digital.cn/7695.html文章源自網(wǎng)吧系統(tǒng)維護-http://www.strong-digital.cn/7695.html
版權(quán)聲明:文章圖片資源來源于網(wǎng)絡(luò),如有侵權(quán),請留言刪除!!!
廣告也精彩
admin
  • 本文由 發(fā)表于 2021年9月27日 10:26:57
  • 轉(zhuǎn)載請務(wù)必保留本文鏈接:http://www.strong-digital.cn/7695.html
匿名

發(fā)表評論

匿名網(wǎng)友 填寫信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: