This article shares with you the specific method of passing parameters to page a to page b for your reference. The specific content is as follows
Method 1: Use HTML5 local storage component (localStorage can store 5M data locally) localStorage is a local permanent storage data, which is the optimization of cookies.
Method 2: Use cookies to store data in the customer's browser (maximum storage of 2M data)
Method 3: Use url to pass arguments (save the data to be passed as a storage variable, and then pass it to url) The method is as follows;
a.html
var app = {};app.list = '123'app.test = '1';window.location.href = "b.html?name="+app;How to convert the character JSON.stringify(app) if the parameter is an object, and then convert it into an object if it is obtained on page b
b.html
Receive the parameters passed by the url
function GetRequest() { var url = location.search; //Get the string after the "?" character in url var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } } return theRequest; } console.log(JSON.parse(GetRequest().name).list)Each browser has restrictions on the length of the URL:
1. The length of the URL is now limited to 2048 bytes bytes (up to 2047 bytes for testing by yourself).
2. The 360 Speed Browser limits the length of the URL to 2118 bytes.
3. Firefox (Browser) limits the length of the URL to 65536 bytes.
4. Safari (Browser) limits the length of the URL to 80,000 bytes.
5. Opera (Browser) limits the length of the URL to 190,000 bytes.
6. Google (chrome) limits the length of the URL to 8182 bytes.
Here, I have only tested IE browser and 360 Speed Browser, and other browsers come from information on the Internet.
Also, I would like to remind you that in the URL, a Chinese character has different sizes through different encoding methods.
The above is how js implements the method of passing parameters to another page. I hope it will be helpful for everyone to learn JavaScript programming.