Having the following HTML
<html>
<head>
<title>bar</title>
</head>
<!-- ... -->
</html>
And invoking window.setTitle('foo');
somewhere within the main process, title remains bar instead of being set to foo
setTitle()
works correctly if the HMTL file doesn't contain a title-node
works when putting setTitle
within webContents
did-finish-load
event.
For future reference, the correct way to set window title is to prevent it from automatically updating to page's title first:
https://github.com/atom/electron/blob/master/docs/api/browser-window.md#event-page-title-updated
Here a complete example:
var win = new BrowserWindow({
width: 800,
height: 600,
title: 'My fixed title'
});
win.on('page-title-updated', (evt) => {
evt.preventDefault();
});
Most helpful comment
Here a complete example: