Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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.

    Lawrence



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


Log in to reply