Introduction
For example, when creating the sharepoint hosted app the custom properties send through querystring.In that process you need to get query string values by jquery.The example codes follows
|
function getUrlVariable() {/* Function to get query string values */
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = decodeURIComponent(hash[1]);
}
return vars;
}
$(document).ready(function () {
var queryVariable = getUrlVariable();/* Assign function to variable */
eListName = decodeURIComponent(queryVariable["listName"]);/* Getting the values */
eEventTitle = decodeURIComponent(queryVariable["eventTitle"]);
});
|
// Function to get the URL parameters
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [,
null])[1]
);
}
$(document).ready(function () {
hostweburl = decodeURIComponent(getURLParameter("SPHostUrl"));
appweburl = decodeURIComponent(getURLParameter("SPAppWebUrl"));
});
|