Results 1 to 5 of 5

Thread: help: script for limit the text selection

  1. #1
    Join Date
    Oct 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help: script for limit the text selection

    I need this thing plz whrer i can find it
    this script can limit the text selection, for examle, if the visitor select all text, then he cannot select all text but he can select only specific number of words or characters such as 20 words only or 200 charaters only.
    so, I dont need script which prevent the select totaly.

    thank you.

  2. #2
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Here: I don't know where it is, but I know how to do it. After the text is selected, make it a string var. Check its length by using .length. If it doesn't fit your needs, the user isn't allowed to select the text.

    -magicyte

  3. #3
    Join Date
    Oct 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you magicyte, but I am poor in programming, I have the code of the script which prvent the selection, can you edit this to select only 20 character :


    this code :
    <script type="text/javascript">

    /***********************************************
    * Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    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"
    }

    //Sample usages
    //disableSelection(document.body) //Disable text selection on entire body
    //disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"

    </script>

    <script type="text/javascript">
    disableSelection(document.body) //disable text selection on entire body of page
    </script>


    thank you.

  4. #4
    Join Date
    Oct 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Plz , any one here can help me

  5. #5
    Join Date
    Oct 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default


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
  •