我正在使用 Electron,我有一个显示外部网站的 webview,但我无法成功显示通常由该网站上的链接打开且目标 = _blank 的附加窗口。
<a href="mentions.html" target="_blank">Mentions légales </a>
我尝试过
webpreferences="nativeWindowOpen=yes" allowpopups
但它没有改变。
使用 webview,您实际上可以很容易地在主进程上处理这些。
如果需要的话,这还允许您禁用nodeIntegration。
// Listen for web contents being created
app.on('web-contents-created', (e, contents) => {
// Check for a webview
if (contents.getType() == 'webview') {
// Listen for any new window events
contents.on('new-window', (e, url) => {
e.preventDefault()
shell.openExternal(url)
})
}
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)