Results 1 to 2 of 2

Thread: selective select

  1. #1
    Join Date
    May 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default selective select

    1) Script Title: Disable Text Selection script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex9/noselect.htm

    3) Describe problem: trying to alter the code to disable all, and allow only certain ones... but its not working... anybody got any ideas? disableing works... but enableing wont

    Code:
    function disablemouse(){
     var target=document.body;
     if(typeof target.onselectstart!="undefined") target.onselectstart=function(){return false}
     else target.onmousedown=function(){return false}
    }
    
    function enablemouse(){
     this.onselectstart=function(){return true}
     this.onmousedown=function(){return true}
    }

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Do you mean disable select-text inside certain elements on the page only? You can do this already with the script as is. For example:

    Code:
    <div id="mydiv">Text inside this DIV isn't selectable</div>
    
    <p>Text that IS selectable</p>
    
    <script type="text/javascript">
    var somediv=document.getElementById("mydiv")
    disableSelection(somediv) //disable text selection within DIV with id="mydiv"
    </script>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •