I know how to use this function...
But I only want this function to work on a textarea...
How would I do that!? Also I've tried like document.textname and also getElementById please help!![]()
I know how to use this function...
But I only want this function to work on a textarea...
How would I do that!? Also I've tried like document.textname and also getElementById please help!![]()
Jeremy | jfein.net
http://www.squarefree.com/2006/05/06...rea-selection/
Looks like you'll have to have browser specific code as there are different techniques for IE vs Firefox
Nile (03-02-2008)
Thanks So Much!
But when I do selectionEnd it just prints out how many characters I put..
Last edited by Nile; 03-02-2008 at 06:13 PM.
Jeremy | jfein.net
Why don't you explicitly say for which browser you need which functionality?
You have already been given a hint that there are major differences between the different browsers' implementations of the selection mechanism...
this code will check what text is selected in the text box every .2 seconds and output it to a span.
Code:<span id="output">No Text Selected</span> <hr> <form action="#" method="get"> <textarea id="select" cols="40" rows="5">1234567890 abcdefghijklmnopqrstuvwxyz</textarea><br> </form> <script type="text/javascript"> var int=setInterval(check, 200); function check() { document.getElementById("output").innerHTML = getSelectionInfo(); } function getSelectionInfo() { var rv = ""; var x; x = document.getElementById("select"); if(!document.selection) { //if not IE rv = x.value.substr(x.selectionStart, x.selectionEnd - x.selectionStart); } else { rv = document.selection.createRange().text; } if (rv == null || rv == "") { rv="No Text Selected"; } return rv; } </script>
[Jasme Library (Javascript Motion Effects)] My Site
/\/\@§†ê® §©®¡þ† /\/\@|{ê®
There are 10 kinds of people in the world, those that understand binary and those that don't.
Bookmarks