Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I insert text in a textarea?

2 views
Skip to first unread message

m.wargers

unread,
Apr 2, 2004, 11:45:43 AM4/2/04
to
I have this code:
alert(
textarea.controllers.getControllerForCommand('cmd_insertText').supportsCommand("cmd_insertText"));

This returns true for me, so I would guess that it should work.

This on the other hand:

textarea.controllers.getControllerForCommand('cmd_insertText').doCommand('cmd_insertText','hallo');


returns an error for me:

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIController.doCommand]"
nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame
:: chrome://findtextarea/content/findtextareadialog.js ::
replacetextarea :: line 130" data: no]

What am I doing wrong?

-Martijn

m.wargers

unread,
Apr 2, 2004, 3:30:58 PM4/2/04
to
m.wargers wrote:

Hmm, according to this:
http://lxr.mozilla.org/seamonkey/source/editor/libeditor/base/nsEditorCommands.cpp#711
it is not implemented. Am I right?

Is there any other way to insert text directly into a textarea without
using textarea.value?

m.wargers

unread,
Apr 3, 2004, 8:00:31 AM4/3/04
to

Hmm, found an (ugly) workaround:
I misuse the clipboard functions:
http://www.xulplanet.com/tutorials/xultu/clipboard.html
and cmd_paste seems to work for textareas:
textarea.controllers.getControllerForCommand('cmd_paste').doCommand('cmd_paste');


Well, all this would not be necessary if this bug would be fixed:
http://bugzilla.mozilla.org/show_bug.cgi?id=158071

-Martijn


0 new messages