Static page HTML Jump transfer value of the JS processing techniques _javascript Skills

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.