How to enable a pop up for authentication for electron?(如何启用电子身份验证弹出窗口?)
问题描述
我正在创建一个访问 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.
这篇关于如何启用电子身份验证弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何启用电子身份验证弹出窗口?


- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01