0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for replying. I can get the script's URL using ScriptApp.getService().getUrl() on the server side, but it doesn't get the URL parameters. I seem to be only able to get the URL parameters in the doGet(), but I don't know how to take the parameters from there and pass them over to Javascript.
If you have them in the doGet(), you can always store them in PropertiesService. Then you can call the PropertiesService from you javascript to get them back out.
ahhhhhhhhh i was wondering if there was something like that!!!! thanks so much, will try in a bit when i get a minute, and will let you know.
Yep PropertiesService was the ticket, thanks EvSunWoodard.
No Problem. Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.