问题描述
我正在创建一个访问 url 的电子应用程序.当导航到 URL 时,用户单击按钮并被重定向到在 Chrome 中显示此弹出窗口的 URL.
I am creating an electron app that accesses a url. And when navigated to the URL the user clicks on a button and are redirected to a URL that displays this pop up in Chrome.
如何在电子中启用/显示此弹出窗口?默认情况下似乎没有启用它.
How can I enable/show this popup in electron? It doesn't seem to enable it by default.
推荐答案
你在图片上看到的是Chrome打开了一个处理身份验证事件的弹出窗口.
What you see on the picture is that Chrome opens a popup for handle authentication event.
但是,Electron 默认情况下不会弹出这样的弹出窗口,正如 'login'
事件
However, Electron doesn't make such popup by default, as it stated in the documentation of 'login'
event
默认行为是取消所有身份验证,要覆盖它,您应该使用 event.preventDefault()
阻止默认行为并调用 callback(username, password)
凭据.
The default behavior is to cancel all authentications, to override this you should prevent the default behavior with
event.preventDefault()
and callcallback(username, password)
with the credentials.
这意味着,您应该处理 'login'
您的 webContents 的事件 手动打开一个弹出窗口或做任何你想做的事情.
This means, you should handle 'login'
event of your webContents manually and open a popup window by yourself or do whatever you want.
这篇关于如何启用电子身份验证弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!