如何从 QtWebKit 编辑“窗口”、“文档”(宽度、高度)上的属性?
我尝试像这样进行更改(在“导航器”对象上工作)
page->mainFrame()->evaluateJavaScript(
"var navigator=new Object;"
"navigator.someProperty=...");
I tried to change like that(worked on the 'navigator' object)
page->mainFrame()->evaluateJavaScript(
"var navigator=new Object;"
"navigator.someProperty=...");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,我将使用信号 javaScriptWindowObjectCleared
启动就在加载之前,当窗口被清除时。
不过,您可能想在做任何事情之前验证来源。
话虽这么说 - 我不太确定你想要实现什么 - 我不会那样操纵 javascript 范围。维护和部署 javascript 比维护和部署 C++ 更容易。因此,我只是将一个简单的 C++ 对象暴露给 javascript 范围(通过 addToJavaScriptWindowObject),然后让 javascript 代码测试该对象并执行其必须执行的操作。
不管怎样,希望这会有所帮助。
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.