admin管理员组文章数量:1295783
This is a pretty basic question. In electron, how do I check the url/filename of a BrowserWindow?
let win;
app.on('ready', () => {
win = new BrowserWindow();
win.loadFile(path.join(__dirname, 'public', 'main.html'));
win.on('closed', () => {
app.quit();
})
});
Ok, so say, this is the code, say after a certain event happens in a different (add:insert) BrowserWindow, I want to get the url from the main BrowserWindow (win).
let addWin;
ipcMain.on('createAddWin', ()=>{
addWin = new BrowserWindow();
addWin.loadFile(path.join(__dirname, 'public', 'add.html'));
addWin.on('closed', () => {
addWin = null
});
ipcMain.on('add:insert', (e,insertObject) => {
//some event happens
//retrieve url from main window (win)
});
});
How do I go about this, I prefer to not have to send an event to the win to then send the url through ipcRenderer, though this is definitely possible.
This is a pretty basic question. In electron, how do I check the url/filename of a BrowserWindow?
let win;
app.on('ready', () => {
win = new BrowserWindow();
win.loadFile(path.join(__dirname, 'public', 'main.html'));
win.on('closed', () => {
app.quit();
})
});
Ok, so say, this is the code, say after a certain event happens in a different (add:insert) BrowserWindow, I want to get the url from the main BrowserWindow (win).
let addWin;
ipcMain.on('createAddWin', ()=>{
addWin = new BrowserWindow();
addWin.loadFile(path.join(__dirname, 'public', 'add.html'));
addWin.on('closed', () => {
addWin = null
});
ipcMain.on('add:insert', (e,insertObject) => {
//some event happens
//retrieve url from main window (win)
});
});
How do I go about this, I prefer to not have to send an event to the win to then send the url through ipcRenderer, though this is definitely possible.
Share Improve this question edited Jan 14, 2019 at 16:36 x-dune asked Jan 14, 2019 at 16:18 x-dunex-dune 1441 gold badge1 silver badge8 bronze badges 4 |1 Answer
Reset to default 28Getting the window's URL is possible by using the getURL() instance method of the window's webContents instance property:
let currentURL = win.webContents.getURL();
本文标签: javascriptHow to get the url of the BrowserWindowStack Overflow
版权声明:本文标题:javascript - How to get the url of the BrowserWindow? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738413164a2085436.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
window.location.href
? – connexo Commented Jan 14, 2019 at 16:22