gpt4 book ai didi

webview - 无法打开目标 = 空白的 Electron webview 链接

转载 作者:行者123 更新时间:2023-12-02 19:05:21 27 4
gpt4 key购买 nike

我正在使用 Electron,我有一个显示外部网站的 webview,但我无法成功显示通常由该网站上的链接打开且 target = _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)
})
}
})

关于webview - 无法打开目标 = 空白的 Electron webview 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48914542/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com