I have a Electron based browser like application which uses Electron's tag to render client urls. I have my own custom tabs setup using multiple webview tags.
As mentioned in the electron documents, I was using the new-window
event to handle page requests to open urls in a new tab. It could be requested by window.open or an external link like <a target='_blank'>
.
My code which was working fine in most cases when the url is specified and not dynamically added later on.
const webview = document.querySelector('webview')
webview.addEventListener('new-window', (e) => {
const url = e.url;
// used url to render new tabs.
})
Lately i have a client login url which when loaded has a button. The button does not have an anchor tag and no predefined urls specified. When opened in chrome, the button click leads to external link opening in a completely new window. The new window briefly shows 'about:blank' in the url bar but then redirects to the actual url.
When i tried to intercept the same external url using new-window
event in my electron webview, the event returned url which was about:blank
and i couldn't access the redirected url. Has anybody else faced the same issue ?
webview.addEventListener('did-stop-loading', loadstop)
instead of immediatly looking for the url? Reference – Decline