You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a renderer window with a webview tag. The webview loads the guest web pages. One of the pages calls window.open and writes HTML to the new window using the following code:
var printWin = window.open("", "_blank");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
When the guest page calls window.open, the renderer window receives new-window event where I create a new BrowserWindow and pass it back as evt.newGuest parameter. My code looks like following:
webview.addEventListener('new-window', (evt, url, frameName, disposition, options, additionalFeatures) => {
evt.preventDefault();
let nW = ipcRenderer.sendSync(constants.open_new_window_event); // Send a synchronous event to create a new BrowserWindow
event.newGuest = nW;
});
But looks like window.open called from the webview guest page does not receive this newly created window. In the webpage, printWin.document.open(); call fails with "TypeError: Cannot read property 'document' of null"
Is there any suggestion on how to handle window.open calls in the pages loaded in the webview?
Activity
kevinsawicki commentedon May 31, 2017
Accessing
documenton the opened window requires thenativeWindowOpenoption to be set which is now supported on<webview>tags starting in `1.7.2.You do not need to override the
new-windowevent to support this, you should be able to accessprintWin.documentwithout it.Closing this out.