1

Is there any way to start a browser with arguments and read them with JavaScript.

e.g. something like that: chromium-browser -test=123

dummy-js: var test = browser["test"];

nick zoum
  • 7,216
  • 7
  • 36
  • 80
streetmaster86
  • 67
  • 1
  • 1
  • 7

2 Answers2

1

You can start browsers from the command line however as you usually do not need to pass arguments to JS in that way, there is no built in way to do that (directly). However, you can use the URL to pass in some information:

  firefox https://example.com?test=123

That can then easily be accessed from within JS.

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151
0

For any randomly loaded page accessing the launch parameters of the browser - NO. And it shouldn't either.


If you want to get the launch parameters from the startup web page, launch it with ural parameters. They are easily accessible from within JS.


If you want any other web page you are managing to access the launch parameters:

  1. Launch the browser with local html file with url params.
  2. This file should read the url params and save them in the localStorage
  3. Any other web page which would like to access these params should:

    3.1 Contain a hidden iFrame which points to the first local html file

    3.2 Have a function in that file to read the localStorage and do postMessage to the parent window.

Charlie
  • 22,886
  • 11
  • 59
  • 90