Qt 4.8.4 QtWebkit doesn't load Javascript
-
Hello,
I'm using qtwebkit to load webpage inside my app. The HTML is loaded well but the Javascript is never loaded.
Do you know what could be happen ?
Thanks a lot.
-
please make sure:
@
myWebView->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
@If it still doesn't work subclass QWebPage and reimplement javaScriptConsoleMessage():
@
void MyWebPage::javaScriptConsoleMessage ( const QString & message, int lineNumber, const QString & sourceID )
{
qDebug() << "CONSOLE (" << sourceId << ":" << lineNumber << "):" << message;
}
@
Then you can see any javascript error which prevent your script to be loaded. -
Thank you for your response.
I've ensure that I've enabled the javascript attribute.
When I execute "evaluateJavascript('console.log('test')'), the javascript engine does not return any result to invoke MyWebPage::javaScriptConsoleMessage function.
I think the problem is into the WebKit Javascript engine, I am enabling the javascript attribute but it is not enabling it.
I have tried to test a simple web page executing an alert('') function, and if I execute into a desktop envioment (linux X86) it works correctly. If I build the same code into a ARM enviroment, it not works. Any idea?Thank you.
-
Hello,
I have tried to execute this function:
QVariant name = ui->myBrowser->page()->mainFrame()->evaluateJavaScript("function abc(){alert('This page has finished loading!');return 'he'} abc();");
qDebug() << "NAME: " << name.toString();
The result of NAME can be garbage of the buffer?
NAME: "-1.45215999014136e-58" NAME: "-1.45215999014147e-58" NAME: "-1.45215999014158e-58" NAME: "-1.45215999014169e-58" NAME: "-1.45215999014179e-58" NAME: "-1.4521599901419e-58" NAME: "-1.45215999014201e-58" NAME: "-1.45215999014212e-58" NAME: "-1.45215999014222e-58" NAME: "-1.45215999014233e-58" NAME: "-1.45215999014244e-58" NAME: "-1.45215999014255e-58" NAME: "-1.45215999014265e-58"
I am using QT 4.8.4 version, and with older versions I had not problems.
Thanks.