五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現在的位置: 365建站網 > 365文章 > html+css中讓網頁禁止右鍵菜單的方法

html+css中讓網頁禁止右鍵菜單的方法

文章來源:365jz.com     點擊數:2795    更新時間:2020-09-20 14:58   參與評論

通過javascript來實現:

oncontextmenu               右鍵菜單事件
onselectstart                   選中網頁內容事件
oncopy                           復制網頁內容事件

寫法1:

<script type="text/javascript">document.oncontextmenu = function(){return false;};</script>
寫法2:  
也可以直接在<body>標簽上添加屬性,如:java代碼
<body οncοntextmenu="return false">
效果一樣。明白了上面的原理,也就找到了破解的方法,如下:在瀏覽器地址欄(或者 Ctrl + O)輸入以下代碼:

 

javascript:alert(document.onselectstart = document.οncοntextmenu= document.onmousedown = document.onkeydown = function(){return true;});


通過css中讓網頁禁止右鍵菜單的方法:

           -webkit-touch-callout: none; /*系統(tǒng)默認菜單被禁用*/
          -webkit-user-select: none; /*webkit瀏覽器*/
          -khtml-user-select: none; /*早起瀏覽器*/
          -moz-user-select: none; /*火狐瀏覽器*/
          -ms-user-select: none; /*IE瀏覽器*/
          user-select: none; /*用戶是否能夠選中文本*/


/*設置IOS頁面長按不可復制粘貼,但是IOS上出現input、textarea不能輸入,因此將使用-webkit-user-select:auto;*/

 *{  
 -webkit-touch-callout:none; 
 /*系統(tǒng)默認菜單被禁用*/ 
 -webkit-user-select:none; 
 /*webkit瀏覽器*/
 -khtml-user-select:none; 
 /*早期瀏覽器*/
 -moz-user-select:none;
 /*火狐*/   
 -ms-user-select:none; 
 /*IE10*/
 user-select:none;
 }
 input,textarea {
 -webkit-user-select:auto; 
 /*webkit瀏覽器*/ 
 margin: 0px;
 padding: 0px;
 outline: none;
 }


如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網友會為你解答!! 點擊進入論壇

發(fā)表評論 (2795人查看,0條評論)
請自覺遵守互聯網相關的政策法規(guī),嚴禁發(fā)布色情、暴力、反動的言論。
昵稱:
最新評論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學習

業(yè)務咨詢

· 技術支持
· 服務時間:9:00-18:00
365建站網二維碼

Powered by 365建站網 RSS地圖 HTML地圖

copyright © 2013-2024 版權所有 鄂ICP備17013400號