I want to run Chrome with js script and url which contains fragment, like this:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --app="data:text/html,<html><body><script>window.resizeTo(200,200);window.location='https://example.com/app?#/mysection';</script></body></html>"
But Chrome cuts everything after '#', so it doesn't work.
I cannot escape this symbol with %23 as far as it will not be recognized as fragment delimiter. I cannot use already prepared *.html file in this script, everything should be generated "on-fly"
How can I resolve this trouble?
I thought to split window.location into window.location.href and window.location.hash. But they cannot be set together.
Maybe it's possible to tell Chrome not to cut script after '#'? Or maybe it's possible to escape '#' into another than %23 way, which can be recognized properly?
PS
"C:\Program Files\Google\Chrome\Application\chrome.exe" --app="https://example.com/app?#/mysection
" works OK, but again I need some JS script to be executed.The #
denotes the beginning of the fragment in the data:
URL, and the fragment is not part of the data. If you escape this as %23
(as MDN says you must), it works, like in this example:
<a href="data:text/html,<script>location.href='https://peter.sh/experiments/chromium-command-line-switches/%23app'</script>">Click here</a>
I therefore cannot follow your statement that
I cannot escape this symbol with %23 as far as it will not be recognized as fragment delimiter.
It works for me:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --app="data:text/html,<script>location.href='https://peter.sh/experiments/chromium-command-line-switches/%23app'</script>"
Note that when you put that in a batch file, you must double the %
, because %2
refers to the second positional parameter of the batch file invocation:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --app="data:text/html,<script>location.href='https://peter.sh/experiments/chromium-command-line-switches/%%23app'</script>"