View Full Version : help: script for limit the text selection
ayman66777
10-21-2008, 09:01 PM
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.
magicyte
10-21-2008, 09:17 PM
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
ayman66777
10-23-2008, 07:27 AM
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.
ayman66777
10-26-2008, 12:44 PM
Plz , any one here can help me
ayman66777
10-29-2008, 11:12 PM
:(:(:(
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.