Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
avascript
JavaScript想要實現在網頁中禁止鼠標右鍵和復制功能常用的有兩種方法,一種是通過在html標簽后面直接加上相應代碼,另一種是在通過JavaScript的加載時實現。
在<body>中加入以下代碼:
<body oncontextmenu="return false" onselectstart="return false">或
<body oncontextmenu="event.returnValue=false" onselectstart="event.returnValue=false">
其中:
1、oncontextmenu="return false"是用來禁止右鍵的;
2、onselectstart="return false"是用來禁止選取文本的;
<script language="Javascript">
document.oncontextmenu=new Function("event.returnValue=false"); //禁止右鍵
document.onselectstart=new Function("event.returnValue=false"); //禁止選取
</script>
效果同上。
Javaweb技術分享
在我們日常的Java web前端開發的過程中呢,程序員們會遇到各種各樣的要求,所以不每天學的東西感覺自己都退步了,都更不上時代的發展了。
每天應對各種需求,每天活在疑問中就是我們程序員的真是寫照。但我們還是一樣熱愛生活,熱愛Java,HTML ,JSP。
在昨天的文章中,我寫了關于Javascript中null 與 undefined 的區別。好像大家都不怎么感興趣,小編感到很失落,不過,沒事,小編還是一如既往的更新,讓大家帶來一些前端的干貨。
Javaweb技術分享
今天我就來教大家一個非常實用的css小技巧----如何禁止選中文字
直接上代碼:
//html 代碼
<p>
Selectable text.
</p>
<p class="noselect">
Unselectable text.
</p>
.noselect {
-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 */
}
在 IE < 10 和Opera < 15中我們需要在需要禁止選中的元素上面添加一個屬性
unselectable="on",否則可能不會生效哦~不過現代瀏覽器如果不是非得兼容一些老的瀏覽器也可以不加。
body{
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}
*請認真填寫需求信息,我們會在24小時內與您取得聯系。