寫一個小筆記,怎么禁止HTML頁面不被選中,復制。
CSS:
*{ moz-user-select: -moz-none; -moz-user-select: none; -o-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -ms-user-select:none; user-select:none; }
屬性有三個屬性值:
1. none:用none,子元素所有的文字都不能選擇,包括input輸入框中的文字也不能選擇。
2. -moz-all:子元素所有的文字都可以被選擇,但是input輸入框中的文字不可以被選擇。
3. -moz-none:子元素所有的文字都不能選擇,但是input輸入框中的文字除外
通過body標簽:
前面一句是禁止右鍵,后面一句是禁止復制。
<body oncontextmenu="return false;" onselectstart="return false">
通過JS實現:
<body onselectstart="return false;"> <table onselectstart="return false;"> </table> </body>