之前做一個網上答題的頁面時,考慮到要防止考生利用復制粘貼來提高作弊的可能性,就設計了不允許復制。
方法也很簡單,通過設置CSS 的 user-select就可以達到目的:
-moz-user-select:none; /* Firefox私有屬性 */ -webkit-user-select:none; /* WebKit內核私有屬性 */ -ms-user-select:none; /* IE私有屬性(IE10及以后) */ -khtml-user-select:none; /* KHTML內核私有屬性 */ -o-user-select:none; /* Opera私有屬性 */ user-select:none; /* CSS3屬性 */
user-select的默認值是 text:可以選擇文本
none:文本不被選擇