Scene:
Similar to popular reviews need to choose the location, and then connect to other pages, in other pages will also use this location and if previously selected location
Method One:
Use session
Sessionstorage is the session store, and the browser is off.
Localstorage is persistent storage and can be used to replace cookies with greater storage space.
Implementation method
Save: sessionstorage["Address"]= "Beijing";
Fetch: sessionstorage["Address"]
Localstorage implementation method is the same as Sessionstorage
Method Two: With the "How to obtain the url# number after the parameter"
Pass the parameters after the URL
b.html?teacher=xx&time=xxx
Back to the problem, first from a.html to b.html need a jump way, for example, in the a.html page you have a link:
<a href="b.html" id="toPageB">跳转到b页面</a>
The rest is good, get the parameters you need, then modify the page URL:
var dataFromLi=[$("#Teachername").text(),$("#Credit_hour").text()];$("#toPageB").attr("href","b.html?data="+dataFromLi);
The URL is then parsed on the b.html page to get the parameters.
How to get parameters based on URLs:
Window.location.search will return all address bars from "?" The starting string. Getting a parameter value can pass regular, here is a simple function to get the parameter:
function getURLParameter(name) { return decodeURIComponent((new RegExp(‘[?|&]‘ + name + ‘=‘ + ‘([^&;]+?)(&|#|;|$)‘).exec(location.search)||[,""])[1].replace(/\+/g, ‘%20‘))||null;}
If you use jquery, you can do it in a simpler way:
$.url().param(‘data‘);
Two page parameter JS