0

I can't use,

window.location = 'chrome://restart'; 

Because then I get this error message:

"Not allowed to load local resource: chrome://restart/"

So what do I do to restart or kill Google Chrome using vanilla Javascript?

Nisarg Shah
  • 14,151
  • 6
  • 34
  • 55
codeWithMe
  • 852
  • 12
  • 17
  • 7
    That sounds like the sort of thing that definitely shouldn't be possible. – CertainPerformance Aug 02 '18 at 05:33
  • 1
    Possible duplicate of [Cannot open local file - Chrome: Not allowed to load local resource](https://stackoverflow.com/questions/39007243/cannot-open-local-file-chrome-not-allowed-to-load-local-resource) – 31piy Aug 02 '18 at 05:33
  • 1
    a web page does not (and should not) have any such access – Jaromanda X Aug 02 '18 at 05:33
  • @31piy Flagged because it's not a possible duplicate. – gotnull Aug 02 '18 at 05:36
  • 1
    @NisargShah `chrome://` pages are a "local resource" – Jaromanda X Aug 02 '18 at 05:36
  • I'm so glad there's no way of killing Google chrome using JavaScript. – gotnull Aug 02 '18 at 05:37
  • 1
    @JaromandaX Not only do the answers fail to specifically address why that's not allowed, but this question is asking "How to restart chrome?", not "How to access chrome://restart". – Nisarg Shah Aug 02 '18 at 05:40
  • @NisargShah -- 1) It is flagged as _possible duplicate_, not _exact duplicate_. If others think that it is exact duplicate, this would have been closed already. 2) I flagged it because _I think_ that it is related to the target question. It is not necessary that I am right, but I tried to search for the problem and found the target question as a suitable candidate. – 31piy Aug 02 '18 at 05:46
  • @NisargShah - sure, that's your opinion, I happen to disagree – Jaromanda X Aug 02 '18 at 06:09

1 Answers1

1

It is possible for local browser to be restarted by JavaScript running in that browser if we have following configuration:

  • local server running on some port, say 12345, localhost:12345
  • this server can accept some API requests, say GET /restart, http://localhost:12345/restart
  • on GET /restart handler our server executes script that kills/re-runs local Browser processes, something like sudo service chrome-remote-desktop restart (follow this, that etc)

Than you need to make an API call to your server from your local browser script with for example fetch...

dhilt
  • 18,707
  • 8
  • 70
  • 85