Re: insert text in textarea on right click in java script
"Max" <maximuszen@opt online.net> wrote in message
news:3a9c1232.0 310132230.1680b f4@posting.goog le.com...[color=blue]
> i want to insert a predefined string in a textarea when i right click
> on the mouse. i need to do it in internet explorer and mozilla.[/color]
Try:
<script type="text/javascript">
var myText = "Predefined text";
function insertText(obj, e){
var button = e.button || e.which;
if (button == 2){
obj.value=myTex t; // or obj.value += myText;
}
}
</script>
<textarea onmousedown="in sertText(this,e vent);"></textarea>
Re: insert text in textarea on right click in java script
"max zen" <maximuszen@opt online.net> wrote in message
news:3f8bf3bf$0 $202$75868355@n ews.frii.net...[color=blue]
> thanks for the reply, but it didn't work in either IE or mozilla.[/color]
Re: insert text in textarea on right click in java script
yes, you're right it does work. i don't know what happened the first
time. the exact function that i am looking for is to insert a "*"
whenever i click in the textarea that already contains text. the
posted function works but only adds the predefined text. i want to
insert into the cursor location the pre defined text. i tried += but
it only appends the predefined text. I will need to insert the
predefined text multiple number of times at different cursor
locations.
Re: insert text in textarea on right click in java script
"Max" <maximuszen@opt online.net> wrote in message
news:3a9c1232.0 310151029.4e51c 980@posting.goo gle.com...[color=blue]
> yes, you're right it does work. i don't know what happened the first
> time. the exact function that i am looking for is to insert a "*"
> whenever i click in the textarea that already contains text. the
> posted function works but only adds the predefined text. i want to
> insert into the cursor location the pre defined text. i tried += but
> it only appends the predefined text. I will need to insert the
> predefined text multiple number of times at different cursor
> locations.[/color]
OK, this works on IE6 (not tested on other browsers).
<script type="text/javascript">
// I found this on
Re: insert text in textarea on right click in java script
The code does work, but incorrectly. It inserts the predefined text into
the previous cursor position. So there is a single click delay. The
predefined text does not appear immediately. On the subsequent click,
the predefined text is inserted into the previous cursor position. Also
we have the context menu pop up also. We lay this away for a while and
have been working on it without the desired solution. I would appreciate
your attention.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Comment