简体   繁体   中英

How to run JavaScript code before document is fully loaded with QWebEngineView?

I would like to evaluate JavaScript before page's document is constructed and its scripts evaluated, in essence emulating Page.addScriptToEvaluateOnNewDocument of Chrome Devtools Protocol.

I tried to evaluate the JS code on loadStarted and loadProgress events of QWebEngineView but the script was evaluated only after page fully loaded.

You can use the QWebEngineScript to do this. It allows you to set an injection point andexecution world for your script (similar to eg greasemonkey).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM