問題描述
我正在創建一個訪問 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.
這篇關于如何啟用電子身份驗證彈出窗口?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!