In chrome, if I go to chrome://flags/ and make a change on the flags page ( enable/disabe features ), a button appears at the bottom of the page which when clicked restarts chrome and re-opens the pages that were opened. Does anyone know what javascript code allows that to happen ?
This is the html where the button appears
<div class="needs-restart" jsdisplay="needsRestart">
<div i18n-content="flagsRestartNotice">NEEDS_RESTART</div>
<button class="experiment-restart-button"
type="button"
i18n-content="flagsRestartButton">RESTART</button>
</div>
Thanks
Hold down the Ctrl key and press the F5 key, or hold the Ctrl key and click the Refresh button.
Close and Reopen Chrome on Windows, Linux, and Chromebook To quit and then reopen Chrome on your Windows, Linux, or Chromebook computer click the “X” icon in Chrome's top-right corner. This closes the browser. To now launch Chrome, search for “Chrome” in your app drawer and select it. This reopens the browser.
A restartBrowser() function is called from the click of that button.
From flags.js:
/**
* Asks the C++ FlagsDOMHandler to restart the browser (restoring tabs).
*/
function restartBrowser() {
chrome.send('restartBrowser');
}
Like the comment implies, it hooks into the C++ code behind Chrome, which will attempt a restart.
Javascript by itself does not allow you to restart the browser. If it did, websites could restart your browser whenever they wanted, which would be annoying for the user. The chrome://flags/ has special permission to interact with the browser and tell it to request a restart. This code is not shown; it's part of Chrome.
I think there is no javascript solution for that but you can type in the url bar : chrome://restart
in order to restart google chrome manually.
If you try this trick using Javascript:
window.location = 'chrome://restart';
then you will get an error message that says "Not allowed to load local resource:"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With