Electron webview new-window event returning `about:blank` as Url

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 ?

I had the same issue with a BrowserWindow and I solved by using the nativeWindowOpen flag (experimental at this time)

It is also available for webviews


In my case, I was able to find the eventually-opened url by adding a will-navigate listener for the popup window's web-contents:

app.on("web-contents-created", (webContentsCreatedEvent, contents)=>{
    contents.on("will-navigate", function(e, reqUrl) {
        console.log(`Popup is navigating to: ${reqUrl}`);