Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox document.execCommand('insertText', ...)

I know FireFox can deal with execCommand pretty well but this time I think I encountered a bug.

But maybe I'm just overlooking something.

I do have a textarea where I am executing insertText which just works fine as long as I am leaving the textarea or writing into it. When I want to execute a second time, it is written in text but not in value. Is it because of insertText?

Here is my example:

<!doctype html>
<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <textarea designMode="on" id="textarea"></textarea>
        <a href="#" onclick="document.getElementById('textarea').focus(); document.execCommand('insertText', false, 'Text'); return false;">Insert text</a>
        <a href="#" onclick="document.getElementById('textarea').value = ''; return false;">Reset</a>
    </body>
</html>

Does anyone have a solution for that? Unfortunately it isn't possible to use a div contenteditable.

Tested in FireFox 41.0.2 with no Add-Ons enabled.

like image 884
webprogrammer Avatar asked Oct 19 '22 23:10

webprogrammer


1 Answers

The command document.execCommand('insertText', false, 'Text') doesn't work in Firefox for textarea.

See bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1220696

like image 111
Nux Avatar answered Nov 24 '22 02:11

Nux