This file contains 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
"use strict"; | |
$(document).ready(function () { | |
var ctag; | |
// Get the URI decoded app web URL. | |
var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl")); | |
// Get the ctag from the SPClientTag token. | |
ctag = decodeURIComponent(getQueryStringParameter("SPClientTag")); | |
// The resource files are in a URL in the form: | |
// web_url/_layouts/15/Resource.ashx | |
var scriptbase = appweburl + "/_layouts/15/"; | |
// Dynamically create the invisible iframe. | |
var blankiframe; | |
var blankurl; | |
var body; | |
blankurl = appweburl + "/Pages/blank.html"; | |
blankiframe = document.createElement("iframe"); | |
blankiframe.setAttribute("src", blankurl); | |
blankiframe.setAttribute("style", "display: none"); | |
body = document.getElementsByTagName("body"); | |
body[0].appendChild(blankiframe); | |
// Dynamically create the link element. | |
var dclink; | |
var head; | |
dclink = document.createElement("link"); | |
dclink.setAttribute("rel", "stylesheet"); | |
dclink.setAttribute("href", scriptbase + "defaultcss.ashx?ctag=" + ctag); | |
head = document.getElementsByTagName("head"); | |
head[0].appendChild(dclink); | |
}); | |
// Function to retrieve a query string value. | |
// For production purposes you may want to use | |
// a library to handle the query string. | |
function getQueryStringParameter(paramToRetrieve) { | |
var params; | |
var strParams; | |
params = document.URL.split("?")[1].split("&"); | |
strParams = ""; | |
for (var i = 0; i < params.length; i = i + 1) { | |
var singleParam = params[i].split("="); | |
if (singleParam[0] == paramToRetrieve) | |
return singleParam[1]; | |
} | |
} |