JAVASCRITP Add the URL parameter method, the parameter added to the URL, if the original URL is covered, the following through the code examples for you to explain the details, please see below.
The JS code looks like this:
function Addtourl (obj) {var aprotocol = Location.protocol;
var ahost = Location.host;
var apath = Location.pathname;
var asearch = Location.search;
var ahash = Location.hash;
var result = ';
Console.log (obj);
var joinobj = function (joinobj_obj) {var result = ';
for (var i in joinobj_obj) {result = i + ' = ' + joinobj_obj[i];
return result;
};
var splitsearchtoobj = function (str) {var resobj = {};
var arr = str.split (' & ');
for (var i =; i < arr.length; i++) {resobj[arr[]] = arr[];
return resobj;
};
var existobjkey = function (Existobjkey_obj, str) {for (var i-existobjkey_obj) {if (i = = str) {return true;
return false;
};
var objextend = function (obj, obj) {var result = {};
for (var i in obj) {if (Existobjkey (obj, i)) {result[i] = Obj[i];
}else{Result[i] = obj[i];
}
}
};
if (Asearch = = ") {console.log (obj);
result = Aprotocol + '//' + ahost + apath + '? ' + joinobj (obj) + Ahash; }else{var oldsearchobj = splitsearchtoobj (asearch.SUBSTR ());
result = Aprotocol + '//' + Ahost + apath + joinobj (objextend (oldsearchobj, obj)) + Ahash;
return result; } addtourl ({' kd ': ' AAA '});
JavaScript add change URL parameter
function Changeparam (name,value)
{
var url=window.location.href;
var newurl= "";
var reg = new RegExp ("(^|)" + name + "= ([^&]*) (|$)");
var tmp = name + "=" + value;
if (Url.match (reg)!= null)
{
newurl= url.replace (eval (reg), TMP);
else
{
if (url.match ("[\?]"))
{
newurl= URL + ' & ' + tmp;
}
else
{
newurl= URL + "?" + tmp;
}
}
Location.href=newurl;
}
The above is a small set to introduce JAVASCRITP add URL parameters and adding parameters to the URL and change the URL parameters of the method, I hope to help you, more information please visit the cloud-Habitat community website to learn more.