You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2006/02/17 21:58:38 UTC

Re: [OT} help required with script.

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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org