Repository navigation
Closed
Description
Hi, I'm facing a problem that window.opener is null when there is a access to window.opener in a page within webview tag.
I listen the new-window event of the webview tag,and then add a new tab.Yes, it's similar to click a a tag with _blank .
The original behavior is that opening a new window in Chrome of window.opener.But now,I changed it to act as clicking a tag with _blank .
I found a doc in https://github.com/electron/electron/blob/master/docs/api/window-open.md.
The sample code is strange,when I opened an url directly,I couldn't access window.opener in new page.
like this:
main.js
const {app, BrowserWindow, m} = require('electron');
let basicWindowParams = {
show: true
};
console.log(process.pid)
app.on('ready', () => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nativeWindowOpen: true
}
})
mainWindow.webContents.on('new-window', (event, url, frameName, disposition, options, additionalFeatures) => {
if (frameName === 'reddit') {
event.preventDefault()
Object.assign(options, {
modal: true,
parent: mainWindow
})
let newWin = new BrowserWindow(options);
event.newGuest = newWin;
newWin.webContents.openDevTools();
}
});
mainWindow.loadURL(`file://${__dirname}/index.html`)
});index.html
<html>
<body>
<script>
let url = 'https://reddit.com';
let modal = window.open(url, 'reddit')
// modal.location.href = url;
</script>
</body>
</html>OS: Windows 7 SP1
Electron: 1.7.8
Reacted by Hyouk Joon Lee
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]window.opener is null :)[/-][+]window.opener is null :([/+]MarshallOfSound commentedon Dec 19, 2017
Duplicate of #10401 #9581
window.openersupport doesn't quite work in Electron primarily due to our process model, this may change at some point in the future.xzycn commentedon Dec 19, 2017
@MarshallOfSound Actually,I write a minibrowser using Electron(1.7.8), there is a calling of window.open within one webview like this:
There is no iframe in my case,dose this is similar to #10041 and #9581? :)
MarshallOfSound commentedon Dec 19, 2017
@xzycn It is the same underlying issue
xzycn commentedon Dec 19, 2017
@MarshallOfSound Thanks for your reply.This is a very bad message to me,the browser has cast my much time :( :(.
Do you have a plan or a schedule to fix the issue? :)