If I have my application execute back to back evalutatejavascript calls using the same frame object, the second call always throws a javascript TypeError: Type error message.
If I combine all the javascript/jquery into one evaluatejavascript call, then it works fine. Which is what I am going to do. But, the issue has me concerned since evaluatejavascript is used quite a bit in our application.
streamJavascript("$(\"#on-screen-time\").text(\"" + hourMinAmPmPattern.cap(1) + "\");");
streamJavascript("$(\"#on-screen-ampm\").text(\"" + hourMinAmPmPattern.cap(2) + "\");");
void AdiTimeManager
::streamJavascript(QString javascript
) {
streamJavascript << javascript;
ADIGlobal::sendJavascript(frame, sJavaScript);
}
void ADIGlobal
::sendJavascript(QWebFrame
*frame,
QString sJavascript
) {
if ( sJavascript != "" )
{
if ( Log4Qt::Logger::logger("ADIGlobal") )
{
Log4Qt::Logger::logger("ADIGlobal")->debug() << "sendJavascript " << sJavascript;
}
frame->evaluateJavaScript(sJavascript);
}
}
08:38:16.135 DEBUG [ADIGlobal] sendJavascript $("#on-screen-time").text("8:38");
08:38:16.225 DEBUG [ADIGlobal] sendJavascript $("#on-screen-ampm").text("AM");
08:38:16.225 DEBUG [AdiWebPage] TypeError: Type error
08:38:16.225 DEBUG [AdiWebPage] 1:
streamJavascript("$(\"#on-screen-time\").text(\"" + hourMinAmPmPattern.cap(1) + "\");");
streamJavascript("$(\"#on-screen-ampm\").text(\"" + hourMinAmPmPattern.cap(2) + "\");");
void AdiTimeManager::streamJavascript(QString javascript)
{
QString sJavaScript;
QTextStream streamJavascript(&sJavaScript);
streamJavascript << javascript;
ADIGlobal::sendJavascript(frame, sJavaScript);
}
void ADIGlobal::sendJavascript(QWebFrame *frame, QString sJavascript)
{
if ( sJavascript != "" )
{
if ( Log4Qt::Logger::logger("ADIGlobal") )
{
Log4Qt::Logger::logger("ADIGlobal")->debug() << "sendJavascript " << sJavascript;
}
frame->evaluateJavaScript(sJavascript);
}
}
08:38:16.135 DEBUG [ADIGlobal] sendJavascript $("#on-screen-time").text("8:38");
08:38:16.225 DEBUG [ADIGlobal] sendJavascript $("#on-screen-ampm").text("AM");
08:38:16.225 DEBUG [AdiWebPage] TypeError: Type error
08:38:16.225 DEBUG [AdiWebPage] 1:
To copy to clipboard, switch view to plain text mode
Added after 57 minutes:
Update.
Apparently, this has nothing to do with multiple calls. All calls are throwing the error, but after every other evaluatejavascript call.
Bookmarks