Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Text selection disable & Opera Browser

    While the scipt works fine on all browsers except Opera Browser. Input fields and drop down menu becomes unclickable, how to fix it?

    My example page:

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

    Head:

    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>

    Body:


    Code:
    <script type="text/javascript">
    disableSelection(document.body) 
    </script>
    
    <script type="text/javascript">
    var somediv=document.getElementById("layer1")
    disableSelection(somediv) 
    </script>
    P.S
    You can choose install Opera as portable in installation options.
    Last edited by tunayx; 12-10-2012 at 05:48 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    I can't see that code in the page you linked to?!

    Anyway, the calls to disableSelection should not be made until the page has loaded.

    Check your browser console for error messages. Mine (GC) says it couldn't load the resource http://js-kit.com/ratings.js. I don't have Opera installed currently.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Sorry, I reupload the example page. You can now see the correct page.

    Btw you can choose install Opera as portable in install options.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    That script does nothing useful at all - all anyone need do is to turn JavaScript off for your page so that it doesn't run - something that anyone likely to want to be able to do would have an option displayed in their browser status bar to do with one click.

    The only situation where anything to do with "disable" something works with JavaScript is where the visitor to your page disables the script that is blocking what they want to do.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    It works for me in the recent version of Opera for Windows, but you do not have a third field in your form which causes an error.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #6
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Could you explain the third field please?

  • #7
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Screenshot attached re. third.
    Attached Thumbnails Attached Thumbnails Text selection disable &amp; Opera Browser-opera1.jpg  
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #8
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    But how to fix it, in my web page there's no such line?

  • #9
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Quote Originally Posted by tunayx View Post
    But how to fix it, in my web page there's no such line?
    There is when I view the source for your page, unless you are using some kind of templating system..
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #10
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I have uploaded an unprotected page below. ıt has also has the third error but input fields are working, so it's not the cause.

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


  •  

    Posting Permissions

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