Execution of a JavaScript function into WebView



  • Into an application that use a WebView I am loading some web content. Trying to execute a JavaScript code that call a alert() window directly into evaluateJavaScript() is fine, but calling it into a function it fails and I am interest into some functions execution into my application.

    [code]QString strTest1 ("alert("this is sly!"); null ");
    QVariant f1result = webView->page()->mainFrame()->evaluateJavaScript( strTest1 ); // fine
    QString strTest2 ("function alert_something() { alert("this is sly!"); } ");
    QVariant f2result = webView->page()->mainFrame()->evaluateJavaScript( strTest2 ); // bad

    qDebug() << f2result.toString(); // returns nothing[/code]

    I can't figure why calling that trivial function call fails... Ideas? I'm open to alternatives, too.



  • Solved. I forgot the alert_something() function call.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.