A Google gadget is an iframe embedded in a gadget container like Google Sites. Example: https://sites.google.com/site/michaelmccolin/test
However, since Google gadgets and Google Sites are on two different domains you cannot get the gadget parent URL using window.parent.location. The good news is the parent URL is included as a parameter value in the gadget (iframe) URL. Example:
https://slr19h92al8so047kuchhg5aog1sb42l-a-sites-opensocial.googleusercontent.com/gadgets/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/116132513635841516857/sample.xml&container=enterprise&view=default&lang=en&country=ALL&sanitize=0&v=3bad4b3f87c8b199&libs=core&mid=167&parent=https://sites.google.com/site/michaelmccolin/test#st=e%3DAIHE3cDvCGmbZDEAvjS%252BWTpqst9FseOLNB%252BMd8IoyLxY3kypcxAriuGzs%252FtCova0JAhrFqKK2kKB3qFgru2PBUTYWMIIcmPaw4iAl7DIaUqyPKO56DpM9mcbQqh1bIa23t89yrL7maxL%26c%3Denterprise&rpctoken=9057528913578437337
The question is how I can get the parent parameter value from the gadget URL.
Thanks!
You can access the query string as follows:
From there on, it's easier to split it at the delimiters and create an object out of it:
Next, retrieve the
parentkey: