Project

General

Profile

Wt-3.3.1 doJavaScript with WTextEdit results in 80020101 error IE8

Added by con abs almost 11 years ago

The following code demonstrates a button for inserting line break in tinymce editor, using tinymce API getInstanceById and getRng.

It works fine in Firefox, but failed with the 80020101 error in ie8.

#include <Wt/WPushButton>
#include <Wt/WServer>
#include <Wt/WTextEdit>
using namespace Wt;

#include <string>
using namespace std;

class App : public WApplication {
    private:
        WTextEdit* edit;
        WPushButton* button;

    public:
        App( WEnvironment const& env ) : WApplication( env ) {
            edit = new WTextEdit( "hello,world!", root() );
            edit->setHeight( 400 );
            button = new WPushButton( "insert line break", root() );
            button->clicked().connect( this, &App::insertLineBreak );
        }

        void insertLineBreak() {
            string editorId = edit->id();
            string js = "var ed = tinyMCE.getInstanceById('" + editorId + "'); var range = ed.selection.getRng(); var newNode = ed.getDoc().createElement ( 'br' ); range.insertNode(newNode);";
            doJavaScript( js );
        }

};

WApplication* createApp( WEnvironment const& env ) { return new App( env ); }

int main( int argc, char* argv[] ) {
    WServer server;
    server.setServerConfiguration( argc, argv, WTHTTP_CONFIGURATION );

    server.addEntryPoint( Application, createApp, "" );

    if( server.start() ) {
        WServer::waitForShutdown();
        server.stop();
    }

    return 0;
}

Replies (2)

RE: Wt-3.3.1 doJavaScript with WTextEdit results in 80020101 error IE8 - Added by Koen Deforche almost 11 years ago

Hey,

IE8 is not as standards compliant as you wish, i.e. it does not implement insertNode() on a selection range.

See also: http://msdn.microsoft.com/en-us/library/ie/ms535872(v=vs.85).aspx

Perhaps, for IE, you can use pasteHtml() after first using setEndPoint() first to make the range 0 bytes wide.

Regards,

koen

    (1-2/2)