zoukankan      html  css  js  c++  java
  • 禁止文本(文字)选中效果

    //js 方法一

    <script>
    window.onload=function(){
      if(document.all){
        document.onselectstart= function(){return false;}; //for ie
      }

      else{
        document.onmousedown= function(){return false;};
        document.onmouseup= function(){return true;};
      }
      oDiv.onselectstart = new Function('event.returnValue=false;');
    }
    </script>

    方法二:css

    -moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;user-select:none;

    结合的写法

    <div id="test" style="-moz-user-select: none; " onselectstart = "return false;" >这里的文字不能选中了</div>

    ------------------------

    if(document.all)
    {
       obj.onselectstart = function(){return false;}; //for ie
    }
    else
    {
       obj.onmousedown = function(){return false;};

       obj.onmouseup = function(){return true;};
    }

  • 相关阅读:
    GDOI模拟赛Round 1
    Codeforces 241B
    Codeforces 325E
    Codeforces 235E
    Codeforces 293B
    Codeforces 263E
    快速傅里叶变换FFT
    后缀自动机
    NOI2011 Day2
    NOI2014 Day2
  • 原文地址:https://www.cnblogs.com/zhengyan/p/4930569.html
Copyright © 2011-2022 走看看