Control Popups on electron webview


#1

I have an app with the following structure
Main window
|----webview1
|----webview2
i want popups triggered from webview one to open on webview2
I have tried the following but nothing seems to work
webview.addEventListener(‘new-window’, (e) => {
webview1.loadURL(e.url);
});

also tried it from the mainwindow perspective
win.webContents.on(‘new-window’, function(e, url) {
webview1.loadURL(url);
e.preventDefault();
});
but it doesn’t seem to work thanks in advance


#2

Maybe you forgot the e.preventDefault()?


#3

I actually figured out it was a problem with my installation…Thank you for your answer.

	webviewMain.getWebContents().on('new-window', function(e, url_link) {
		    popup1.loadURL(url_link);
		    console.log(String(url_link));
		   e.preventDefault();
		});

currently this is what works for me except for the popup1.loadURL();
which doesn’t for some reason it gives me Segmentation Fault errors.
I am posting the issue over at Github for now.