Bharathi Kattamuri wrote:
Hi,

I have with javascript in a struts application. I am trying to insert a text into a TextArea. Somehow document.selection.createRange().text is not working. I am using IE6.0.29

Below is the code.

<script type="text/javascript" language="javascript">
     function addToMessageText(sendText){
      // alert("addToMessageText: "+ sendText);
       var selectedText = document.selection.createRange().text;
       alert("selectedText : "+ selectedText );
       if (selectedText != ""){
              document.selection.createRange().text = sendText ;
       }
   }

</script>

and calling the method from a button. Somehow document.selection.createRange().text is not working.

<a class="linkButton" onclick="addToMessageText('%%FIRSTNAME')" ><bean:message key="label.firstname"/></a>

Any suggestions is appreciated.

Bharathi.

I suggest you ask on a Javascript-related list ;-)

Selection support is notoriously inconsistent between browsers. If you need to support more than one browser (i.e. you're not developing strictly for a controlled intranet environment), you'll be doing yourself a big favour if you look into using a good Javascript framework, such as Dojo, instead of trying to work around the browser inconsistencies yourself.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to