最近在寫頁面的時候,需要在左上角加一個logo,但是復制的時候會把這張圖片一塊選中。
那么我們可以通過css給它設置禁止選中,代碼如下:
.icon { -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Chrome/Safari/Opera */ -khtml-user-select: none; /* Konqueror */ -moz-user-select: none; /* Firefox */ -ms-user-select: none; /* Internet Explorer/Edge */ user-select: none; /* Non-prefixed version, currently not supported by any browser */ }
添加禁止代碼后,該圖片就不能被選中了。
豌豆資源搜索網站https://55wd.com 廣州vi設計公司http://www.maiqicn.com
html頁面內容禁止選擇、復制、右鍵
剛才在一個站點的源代碼的的時候發現的,其實原來真的很簡單
<body leftmargin=0 topmargin=0 oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false' onmouseup='document.selection.empty()'>
關鍵就在
oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false' onmouseup='document.selection.empty()'
一個更簡單的方法就是在<body>中加入如下的代碼,這樣鼠標的左右鍵都失效了。
topmargin="0" oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()"
1、禁止網頁另存為:在<body>后面加入以下代碼:
<noscript> <iframe src="*.htm"></iframe> </noscript>
2、禁止網頁內容復制.粘貼:在<body>中加入以下代碼:
<body onmousemove=/HideMenu()/ oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()">