I'm adding a script tag to a web page once it's fully loaded in a WebEngineView
, but it's silently failing somehow.
I inject the script by invoking webview.runJavaScript
with this code:
var s = document.createElement('script');
s.src = "qrc:/jquery-2.1.4.min.js";
document.body.appendChild(s);
That's perfectly standard and to a certain extent it works as expected, i.e., if I view the html
source of the page, the script tag has indeed been appended to the body.
The problem is that the script isn't being downloaded, or isn't being evaluated, or something. All I know is in the above example the jQuery functions aren't available. If I load a small JavaScript test file with one global variable, that variable's not available either. Changing the url to http instead of qrc and pointing it to a web server makes no difference.
Injecting an img
tag works fine; the image is loaded and displayed.
But JavaScript is broken somehow. Does anyone know how to fix this?