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 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts

    toggle disableselect with radio buttons?

    Hello,

    I'd like to know if the following script (or something similar) can be modified to use "on" and "off" radio buttons to toggle disableselect... preferably loading the page with the "on" button selected.

    Thanks for any help:


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

    <script>
    function disableselect(){
    return false
    }
    function reEnable(){
    return true
    }
    document.onselectstart=new Function ("return false")
    {
    document.onmousedown=disableselect
    document.onclick=reEnable
    }
    </script>

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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    197
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Looks alot like a script i once saw on Dynamic drive .. what exactly does it do?
    ez
    Animation Rule #64
    Poor quality images are often artistic,
    Poor quality sound is ALWAYS annoying.

  • #3
    New Coder
    Join Date
    Jan 2003
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what exactly does it do?

    It prevents the highlighting/selection of content, such as text.

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Strictly IE.

    <html>
    <head>

    <script type="text/javascript">

    function toggle_selectable(bWhich, bClear) {
    document.onselectstart.isEnabled = bWhich;
    if (bClear) document.selection.empty();
    }

    document.onselectstart = function() {
    return document.onselectstart.isEnabled;
    }

    document.onselectstart.isEnabled = false;

    </script>
    </head>
    <body>
    <hr />
    <form>
    <input name="toggle_hilite" type="radio"
    onclick="toggle_selectable(true)" />content selectable
    <input name="toggle_hilite" type="radio" checked="checked"
    onclick="toggle_selectable(false, true)" />content unselectable
    </form>
    <hr />
    <h1>This is header 1</h1>
    <h2>This is header 2</h2>
    <p>This is a paragraph</p>
    </body>
    </html>

  • #5
    New Coder
    Join Date
    Jan 2003
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    That works nicely; thanks.


  •  

    Posting Permissions

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