0
votes

I have a web app with Google Apps Script and would like to take a URL parameter and use it in modifying my HTML via Javascript, but am finding this tricky.

If I try using window.location in my Javascript it gives a different URL than the one shown in the address bar. The URL shown in the address bar is like this ... https://script.google.com/macros/s/MY_SCRIPT_ID/exec?param1=value1 .... but window.location gives something like this https://SOME_SORT_OF_LONG_ID-script.googleusercontent.com/userCodeAppPanel (it doesn't have param1 / value1 at all).

I know how to get the parameter value when I'm in the doGet(e) function -- by using e.parameter.param1 -- but I don't know how to be able to then subsequently use that value in some Javascript.

Help, please!

1

1 Answers

1
votes

The html that GAS provides is never the actual URL, it is essentially another ID that google uses to keep track of its web pages. Remember that all Google apps are running on the Google server.

This may not be the same with a standalone script, but I suspect it will be, but I know if you get a google doc, the actual URL is:

https://docs.google.com/document/d/{{{ Your Document ID }}}

I expect a standalone app will be similar. Try using your webapp.getId(), and then adding it to the actual url of your script.