How to catch "window.onload" webpage event ?

  • Hi,

    I am using QtWebKit in Qt 4.8.

    I want to know that when could I execute the following Qt code to insert a javascript function for handling the "window.onload" webpage event :

    webview->page()->mainFrame()->evaluateJavaScript("window.onload = function() {alert('test');};");

    Should I execute the above code when the "loadStarted()" signal of a QWebView emits ? or should it be executed at other times ?

    Thanks in advance for any suggestion.


  • Maybe you could try QWebFrame::javaScriptWindowObjectCleared() or loadFinished().
    But loadStarted() would be to early I think.

Log in to reply