Calling preventDefault() on new-window event doesn’t prevent window opening

According to the docs the following should prevent the window from being opened but the new window is still being opened.

window.webContents.on('new-window', function(event, urlToOpen) {
  event.preventDefault();
});

Doing the following instead seems to work though:

window.webContents.on('new-window', function(event, urlToOpen) {
  event.defaultPrevented = true;
});

Using 0.19.0

1 thought on “Calling preventDefault() on new-window event doesn’t prevent window opening

Comments are closed.