如何从 QtWebKit 编辑“窗口”、“文档”(宽度、高度)上的属性?

发布于 2024-11-26 22:55:14 字数 168 浏览 1 评论 0原文

我尝试像这样进行更改(在“导航器”对象上工作)

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揽月 2024-12-03 22:55:14

在这种情况下,我将使用信号 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文