Reputation: 101
I am new to electron and I am not able to figure out how to open a particular web page in BrowserWindow when native menu item is clicked.
Could anyone help me with this.
Regards, Ajay
Upvotes: 0
Views: 2644
Reputation: 3033
use loadUrl
method of the BrowserWindow
inside your click event.
eg:
win = new BrowserWindow({width: 800, height: 600})
const template = [
{
label: 'Custom',
submenu: [
{
label: 'navigate',
click ()
{
win.loadURL('https://electron.atom.io');
}
}
]
}
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
// and load the index.html of the app.
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
Upvotes: 1