I have a provider-hosted, on-premise app using SharePoint 2013.
The Chrome control works fine when first accessing the app from SharePoint, however, on subsequent pages, the chrome control does not work.
I figured that since my links within the application would not all have the SPHostUrl or SPAppWebURl in the query string parameters, I would store them in a cookie for use on subsequent pages. This much works, in both cases I get the script url of http://{hostWeb}/_layouts/15/SP.UI.Controls.js
However, when I try to apply the chrome control with the code:
var sharepointScript = sharepointHostWebUrl + "/_layouts/15/SP.UI.Controls.js";
$.getScript(sharepointScript, function () {
var options = {
"appIconUrl": "/Content/images/AppIcon.png",
"appTitle": appTitle,
"settingsLinks": [
{
"linkUrl": "http://www.google.com",
"displayName": "Google"
},
{
"linkUrl": "http://www.microsoft.com",
"displayName" : "Microsoft"
}
]
};
var nav = new SP.UI.Controls.Navigation("Chrome", options);
nav.setVisible(true);
});
then the initial page from SharePoint works, but subsequent pages get the JavaScript error:
Error: Error: The app's host site url is not set.
Source File: http://{hostweb}/_layouts/15/SP.UI.Controls.js?_=1369967456299
Line: 2
I also tried changing to AppWeb instead of hostWeb, but got the same results.
How can I make the Chrome control work on subsequent pages?