未在 webview iframe 中执行的预加载脚本

Ale*_*lex 5 javascript iframe webview node.js electron

呈现器进程中存在的 Webview 标记,位于<body>

<webview src="http://somewebpage.com" preload="somescript.js">
Run Code Online (Sandbox Code Playgroud)

somescript.js在 somewebpage 中执行,但是如果 somewebpage 中有<iframe>s ,则脚本将不会在 iframe 中运行。

我怎样才能让它运行?在 iframe 中的任何其他脚本之前?

我在 github 上发现了这个似乎相关的问题:https : //github.com/electron/electron/pull/19260 但它没有任何意义......

我尝试添加nodeintegrationinsubframes并将值从 false 更改为 true

<webview src="somewebpage" preload="somescript.js" nodeintegrationinsubframes="false">
Run Code Online (Sandbox Code Playgroud)

但它没有效果:(

小智 1

我的项目遇到了同样的问题,并将电子更新到最新的测试版本为我解决了。

我假设你知道如何做到这一点:

npm install electron@11.0.0-beta.6
Run Code Online (Sandbox Code Playgroud)

您仍然需要考虑使用该包的开发版本的稳定性问题。