开发者

How to edit a property on 'window', 'document'(width,height) from QtWebKit?

I tried to change like that(worked on the 'navigator' object)

page->mainFrame()->evaluateJavaScript(
    "var navigator=new开发者_如何学运维 Object;"
    "navigator.someProperty=...");


In that case, I would use the signal javaScriptWindowObjectCleared

That kicks in just before load, when the window has been cleared.

You probably want to validate the origin before doing anything, though.

That being said - and I am not too sure what you want to achieve - I wouldn't manipulate the javascript scope like that. Maintaining and deploying javascript is easier than doing the same for C++. So, I would instead just expose a simple C++ object to the javascript scope (via addToJavaScriptWindowObject), and then have the javascript code test this object and do what it has to do.

Either way, hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜