Re: Textarea text selection problem in Firefox

Giganews Newsgroups
Subject: Re: Textarea text selection problem in Firefox
Posted by:  Mark Szlazak (mszlaz…@aol.com)
Date: 7 Mar 2005

There seems to be a problem with selectionStart when selections include
the first character position of the first line of the textarea. If you
start your selection at any point after that then things work fine. One
could add a space to the beginning of the test then make selections
that start any place after that but then you loose the ability to use
"select all". Does anyone know what going on with this? Here's a
smaller sample script with the same issue.

<html>
<head>
</head>
<body>
<form name="F">
<textarea name="TA" rows="5" cols="40">
Textarea text selection test.
Test for textarea text selection.
</textarea>
<input type="button" value="show selection"
onclick="var ta = this.form.TA;
     if (document.selection) {
         var range = document.selection.createRange();
         if (range.parentElement() == ta)
                alert(range.text);
     }
     else if (ta.selectionStart)
         alert(ta.value.substring(ta.selectionStart, ta.selectionEnd));"
>
</form>
</body>
</html>

Replies

None

In response to

Textarea text selection problem in Firefox posted by Mark Szlazak on 7 Mar 2005