In this article, we describe the JS processing techniques for jump-pass values in static page HTML. Share to everyone for your reference, specific as follows:
In HTML, through the "?" Pass Value:
<a href= "Index2.html?name=caoy" > Static transmit Value </a>
In the page index2.html to jump to receive:
var name=urlparm.parm ("name");
The code is as follows:
Index.html:
<script type= "Text/javascript" src= "geturlparam.js" ></script>
<a href= "Index2.html?name=caoy" > Static Transmit Value </a>
Index2.html:
<script type= "Text/javascript" >
var name=urlparm.parm ("name");
alert (name);
</script>
Geturlparam.js:
Urlparm = function () {//url parameter var data, index;
(function init () {data = [];
index = {};
var u = window.location.search.substr (1);
if (U!= ') {var parms = decodeuricomponent (u). Split (' & ');
for (var i = 0, len = parms.length i < len; i++) {if (Parms[i]!= ') {var p = parms[i].split ("="); if (p.length = 1 | | (P.length = = 2 && p[1] = = ")
{//P | p= data.push ([']);
Index[p[0]] = data.length-1;
else if (typeof (p[0]) = = ' undefined ' | | p[0] = = ') {//=c | = data[0] = [p[1]];
else if (typeof (Index[p[0]]) = = ' undefined ') {//C=aaa Data.push ([p[1]]);
Index[p[0]] = data.length-1;
else {//C=AAA Data[index[p[0]]].push (p[1]);
}
}
}
}
})(); return {//Get parameters, similar to Request.getparameter () parm:function (o) {/o: Parameter name or parameter order try {return (typeof (o) = = ' Numb Er '?
DATA[O][0]: data[index[o]][0]); catch (e) {}},//Get parameter group, similar to Request.getparametervalueS () parmvalues:function (o) {//o: Parameter name or parameter order try {return (typeof (o) = = ' number '? Data[o]: Data[index[o]); catch (e) {}},//Does it contain the Parmname parameter Hasparm:function (parmname) {return typeof (parmname) = = ' String '? typeof (
Index[parmname])!= ' undefined ': false;
},//Get parameter map, similar to Request.getparametermap () parmmap:function () {var map = {};
try {for (var p in index) {map[p] = data[index[p]];}
catch (e) {} return map;
}
}
}();
So you can pass the value through the HTML jump.
More readers interested in JavaScript-related content can view the site topics: "JavaScript switching effects and tips summary", "JavaScript Search Algorithm Skills Summary", "JavaScript animation effects and tips summary", " JavaScript error and debugging skills Summary, JavaScript data structure and algorithm skills summary, JavaScript traversal algorithm and skills summary and JavaScript mathematical calculation usage Summary
I hope this article will help you with JavaScript programming.