问题描述
我有一个简单的 electron.js 应用程序,electron-quick-start 其中我正在使用 .
I have simple electron.js application, electron-quick-start in which I am using <webview>
.
默认情况下,设置了 target=_blank
的链接不会在 webview
内打开.
By default links in which target=_blank
is set does not open inside webview
.
通过听new有一些解决方法-window
事件在 不能使用 target = blank
但是当 nativeWindowOpen: true
in webPreferences
in parent window
But this workaround does not work when nativeWindowOpen: true
in webPreferences
in parent window
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
webviewTag: true,
nativeWindowOpen: true // This flag is not letting recieve new-window event from webview
}
})
如何获得 webview 链接,其中 target=_blank
工作保持 nativeWindowOpen: true
在父窗口中?
How can I get webview links where target=_blank
working keeping nativeWindowOpen: true
in parent window?
nativeWindowOpen
将根据
nativeWindowOpen
is going to be set true
by default according to Planned Breaking API Changes (15.0)
推荐答案
我试过用 Electron fiddle 写一个要点.也许我没有发现你的问题,但对我来说它是有效的https://gist.github.com/deb6ed0fa37860fdfc0d51c6782f4152
I've tried and write a gist with Electron fiddle. Perhaps I didn't catch your problem but for me it's workinghttps://gist.github.com/deb6ed0fa37860fdfc0d51c6782f4152
这篇关于当父窗口中的 nativeWindowOpen 为 true 时,electron.js 中 webview 中基于 target=_blank 的链接不会打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!