I have an Electron app that can open different windows.
On app launch the app open a set of window(s) (that load the same HTML and JS files) but with params to change each window displayed infos.
Example :
app.on('ready', async () => {
...
// open window for stuff 1
win1 = new BrowserWindow({
width: 1024,
height: 728
});
win1.loadURL(`file://${__dirname}/app/app.html?id=1`);
// open window for stuff 2
win2 = new BrowserWindow({
width: 1024,
height: 728
});
win2.loadURL(`file://${__dirname}/app/app.html?id=2`);
Obviously passing params in file:// path doesn't work. I can't find a clear solution in Electron documentation or elsewhere on Internet to condition my rendered window to a param.
I can probably use IPC communication after window ready but it seems a little bit too complicated until I just want pass a variable to my child view.
P.S. : to be totally honest my application is built with React/Redux and the param I want to pass to view is the redux store key to listen for this view.
file://
path works just fine for me. All params are inlocation
as expected. – Pandolfifile://
; That said I also use apreload
script file from which I get a (possibly large) JSON page data string from the main thread and make it available to the page. This way the page data is available already during page load. – Pandolfi