Results 1 to 2 of 2

Thread: Text selection disable script and Opera flaw

  1. #1
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Text selection disable script and Opera flaw

    This script works fine on all other browsers except in Opera, if you drag mouse a little above the (starting of essay) "Evliliğe Dair" then the text can be selected. How to fix this flaw?

    http://www.aymavisi.org/makale/Evlil...20Gibran).html


    Code:
    <script type="text/javascript">
    function disableSelection(target){
    if (typeof target.onselectstart!="undefined") //IE route
    	target.onselectstart=function(){return false}
    else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
    	target.style.MozUserSelect="none"
    else //All other route (ie: Opera)
    	target.onmousedown=function(){return false}
    target.style.cursor = "default"
    }
    </script>

    Code:
    </body>
    <script type="text/javascript">
    disableSelection(document.body) 
    </script>
    
    <script type="text/javascript">
    var somediv=document.getElementById("layer1")
    disableSelection(somediv) 
    </script>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,953
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Change:

    Code:
    </body>
    <script type="text/javascript">
    disableSelection(document.body) 
    </script>
    to:

    Code:
    </body>
    <script type="text/javascript">
    disableSelection(document) 
    </script>
    And if that doesn't work, try putting those scripts before the </body> tag.

    The browser cache may need to be cleared and/or the page refreshed to see changes.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Replies: 6
    Last Post: 12-13-2012, 08:52 PM
  2. Help with Disable Text Selection script
    By snoopygirl11 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-26-2009, 09:03 PM
  3. Disable right click and text selection blogger?
    By smoothfreeze in forum JavaScript
    Replies: 3
    Last Post: 12-02-2008, 03:51 AM
  4. Disable Text Selection
    By sourabhmca in forum JavaScript
    Replies: 0
    Last Post: 11-28-2007, 04:52 PM
  5. Disable Text Selection script problem in Firefox
    By dandyjob in forum Dynamic Drive scripts help
    Replies: 10
    Last Post: 02-02-2007, 02:30 AM

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
  •