Project

General

Profile

to execute simple javascript code

Added by Bruno Zerbo almost 11 years ago

hi guys,

I have a simple class derived form WCompositeWidget.

It is the simple constructor.

MyClass::MyClass(WContainerWidget *parent)
    : WCompositeWidget(parent),
{
    container = new WContainerWidget();
    setImplementation(container);

    if (parent){
        parent->addWidget(this);
    }


    WStringStream strm;
    strm <<"document.write('<p>My First JavaScript</p>');";

    doJavaScript(strm.str());
}

the program works but on execution I gat a popup message with:

Wt internal error: TypeError: a is null, code: undefined, description: undefined

What does it means? What's wrong?

Thank you, Bruno


Replies (1)

RE: to execute simple javascript code - Added by Koen Deforche almost 11 years ago

Hey,

    if (parent){
        parent->addWidget(this);
    }

This should not be necessary as you already passed the parent to the WCompositeWidget constructor.

The reason for the error message is not clear to me; but I would be surprised if it is triggered by the doJavaScript()?

I wouldn't recommend using 'document.write()' although I suspect you're using it for testing here; try to console.log() or alert() instead?

Regards,

koen

    (1-1/1)