html中属性的作用,html的标签中 unselectable=on 属性的作用
在IE瀏覽器中,當input獲得焦點時,點擊有unselectable="on"屬性的標簽時,不會觸發onblur事件。
加上該屬性的元素不能被選中。
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
< html>
< head>
< title>html的標簽unselectable=on屬性的作用
< meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
< /head>
< p>
< p>unselectable="on"
< p>span測試2 unselectable=""
< p>
div測試1 unselectable="on"< p>
div測試2 unselectable=""< /html>
< script language="javascript" type="text/javascript">
(function () {
var txt = document.getElementById("txt");
txt.onblur = function () { alert('失去焦點了'); }
})();
< /script>
在IE下給DIV設置unselectable與onselectstart屬性,可以讓div的內容不能選中,這個功能在很多情況下,非常有用,但是他的bug太明顯,
直接使用一個DIV是可以的,比如:
不能選中的內容但是假如在這個DIV前面在出現一個普通的DIV,那就有問題了,比如:
普通DIV從前面一個DIV開始選,就可以選中本部分內容,只有從該DIV結束部分才能不選中目前我還沒找到很好的解決方案,要么在body里用onselectstart="return false;",但是那會導致整個頁面都無法選中;或者在所有div或者類似DIV的容器里都要設置onselectstart="return false;",才能徹底解決。
Firefox下的解決方案:
style="-moz-user-select:none;"
Chrome下的解決方案:
style="-webkit-user-select:none;"
總結
以上是生活随笔為你收集整理的html中属性的作用,html的标签中 unselectable=on 属性的作用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tcp报文格式_34.TCP取样器
- 下一篇: numberformate php_ph