I have a SharePoint hosted app and I am trying to pull the SPHostUrl
out of the app Url for REST calls.
Everything I read tells me to use the below but for some reason I am getting an error
'GetQueryStringParameter' is undefined
I have tried in a couple of different browsers and even tried just a simple command in the console using the browser developer tools but it seems GetQueryStringParameter()
is not a valid function? am I missing something?
URL
http://app-cb941ae4f1f18e.app.dragon.dev/sites/smrgol/AppPartTest/Pages/Default.aspx?SPHostUrl=http%3A%2F%2Flair%2Edragon%2Edev%2Fsites%2Fsmrgol&SPLanguage=en%2DUS&SPClientTag=2&SPProductNumber=15%2E0%2E4763%2E1000&SPAppWebUrl=http%3A%2F%2Fapp%2Dcb941ae4f1f18e%2Eapp%2Edragon%2Edev%2Fsites%2Fsmrgol%2FAppPartTest
References in Default.aspx
<script type="text/javascript" src="../Scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="../Scripts/App.js"></script>
Line in App.js
var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));