I want open link in new window. Link with hash (#). After hash going page for my JS framework. I do:
const modalPath = path.join('file://', __dirname, 'index.html#','message',chat_id,'child-window');
let win = new BrowserWindow({width: 400, height: 200, show: false, frame: false});
win.loadURL(modalPath);
win.show();
It is worked for mac, but not work for Windows (open only index.html- mainpage)
Using path.join
to build a URL is not a good idea since the path separators will differ between platforms, on Windows you'll end up with something like file://\\dirname\\index.html#\\message\\chat_id\\child-window
, whereas on Mac/Linux you'll get file://dirname/index.html#/message/chat_id/child-window
. What you should do instead is something like:
url.format({
protocol: 'file',
pathname: `${__dirname}/index.html#/message/${chat_id}/child-window`
})`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.