Created
January 28, 2013 23:01
-
-
Save chrisobriensp/4660107 to your computer and use it in GitHub Desktop.
Shows a possible way of working around the apparent bug in SP2013 apps, where the SPHostUrl parameter value is incorrect on subsequent navigation to the app default page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sharePointReady() { | |
| // retrieve passed app web/host web URLs.. | |
| if (_spPageContextInfo != undefined) { | |
| // allow this code to be used in an app part page.. | |
| appweburl = _spPageContextInfo.webAbsoluteUrl; | |
| if ((document.referrer !== "") && (!document.referrer.toLowerCase().startsWith(appweburl.toLowerCase()) && ($.getUrlVar("SPHostUrl")))) { | |
| // we came from outside app web and are being passed SPHostUrl, so this should be the correct value - let's | |
| // store it in a cookie against this path.. | |
| hostweburl = decodeURIComponent($.getUrlVar("SPHostUrl")); | |
| var x = appweburl.replace('://', ''); | |
| var cookiePath = x.substr(x.indexOf('/'), x.length - x.indexOf('/')); | |
| COB.cookieHandler.setCookie(cookieName, hostweburl, null, cookiePath); | |
| } | |
| else { | |
| hostweburl = COB.cookieHandler.getCookie(cookieName); | |
| } | |
| } | |
| else { | |
| hostweburl = COB.cookieHandler.getCookie(cookieName); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment