0

Can I start Google Chrome (from CLI or whatever) passing (as a CLI switch?) an argument string, to be later used in Javascript?

I need to read an environment variable from the browser. I know I can't and I understand why. But since I have control on the (Windows) desktop link that fires up my web application on the clients' machines, I could easily pass that string to Chrome using the aforementioned link.

Is there in the Google Chrome CLI command a switch that lets me store an arbitrary string in something I would call "chrome environment variable" that I can later read with Javascript and send to my server through ajax?

Community
  • 1
  • 1
Pierre Prinetti
  • 9,092
  • 6
  • 33
  • 49
  • Easiest way I can think of is calling Chrome with an URL of your server to open that hosts your JavaScript, including your string in your URL as an argument and fetching it with JavaScript. I just assume your JavaScript is on your server as well, or you will get problems with AJAX at that point. Something like `https://example.com/pass.html?env=arbitary` maybe? – Num Lock Jan 17 '17 at 09:44
  • Booting up Chrome with the string in the provided URL directly as a GET variable is definitely the best solution so far. Thank you! – Pierre Prinetti Jan 17 '17 at 11:42

0 Answers0