www.webdeveloper.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 43

Thread: Unselectable

  1. #1
    Join Date
    Mar 2005
    Posts
    10

    Unselectable

    Hello again!

    I'd like to know if I can make text unselectable in Opera,Netscape.
    In IE there is such property:
    unselectable="on"

    Please help.

  2. #2
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Use disabled instead.
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  3. #3
    Join Date
    Mar 2005
    Posts
    10
    It doesn't work.
    Is there something else instead?


    -- Maxim

  4. #4
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Originally posted by Maxim
    It doesn't work.
    Is there something else instead?
    Yes, it does work.

    Code:
    <input type="text" value="Some text goes here." disabled>
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  5. #5
    Join Date
    Mar 2005
    Posts
    10
    It works only with text fields, but I need to disable text and image that are contained by DIV.


    --Maxim

  6. #6
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Originally posted by Maxim
    It works only with text fields, but I need to disable text and image that are contained by DIV.
    For what?
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  7. #7
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887
    Here, give this a shot:

    Code:
    <body onselectstart="return false">
    unselectable
    </body>

  8. #8
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    onfocus="this.blur";
    Stephen

  9. #9
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    I highly discourage that anyone provide a solution until we know just why this person wants to do this. This is not what JavaScript was made for and is not practical as far as I can see. This would only cripple the UI.
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  10. #10
    Join Date
    Mar 2005
    Posts
    10

    Thumbs up

    Thanx all for interesting offers.

    function captureEvents(){
    return false;
    }
    document.onselectstart = captureEvents;
    document.onselect = captureEvents;
    document.ondblclick = captureEvents;
    document.onmousedown = captureEvents;

    It works in all browsers.

    --Maxim

  11. #11
    Join Date
    Jul 2004
    Posts
    986
    Originally posted by Maxim
    Thanx all for interesting offers.

    function captureEvents(){
    return false;
    }
    document.onselectstart = captureEvents;
    document.onselect = captureEvents;
    document.ondblclick = captureEvents;
    document.onmousedown = captureEvents;

    It works in all browsers.

    --Maxim
    Doesn't work in any of my browsers... Firefox or Internet Explorer...
    Post a link and I'll post a screenshot of me selecting and copying your text and anything else I want from your page...

    .....Willy

  12. #12
    Join Date
    Mar 2005
    Posts
    10
    It does work, when you're trying to select by the mouse.

    It doesn't work when you use the combination Ctrl+A.

  13. #13
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887
    My method even blocks ctrl+A

    You'd best use onselectstart in the body and decide wether or not
    to return true or false depending on what's being selected
    (use another function to figure this one out).

  14. #14
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Originally posted by Ultimater
    My method even blocks ctrl+A

    You'd best use onselectstart in the body and decide wether or not
    to return true or false depending on what's being selected
    (use another function to figure this one out).
    Did you test it only in IE? (Just curious. I didn't test it at all.) Also, why are you going to even answer him? He still hasn't told us why he wants to do this, and I can't see any good reason to do it. If there was a good reason, wouldn't there be some sort of CSS property to disallow text selection? I'm sure the W3C would have thought of it if it were useful. (Granted, they don't think of everything useful off the spot, but disabling text selection isn't something that no one has ever heard about.)
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  15. #15
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887
    Disabling text-selection isn't all-that-deadly.
    It's like disabling right mouse clicks in order to prevent
    source "stealers".
    Works ,but there is always away around.

    So, I could care less if he even gave you a million alerts in-a-row.
    (Not that I would wanna actually visit his site.)

    Don't worry, he'll learn sooner or later that disabling certain
    events is useless.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles