URL's? And # (hash), how to save the parameters in the URL for the variable before obtaining refresh?

URL parameters will bring in, if it is? Beginning, then this will be added to the ajax request, # (hash) equivalent to bookmark anchor for locating pages, will not be added to the ajax request, some when we can put some parameters on the back #

How to obtain the parameters in the URL and parse it out?

let url = location.search; // get the url string after the character "?"
let theRequest = new Object();
if (url.indexOf("?") != -1) {
  let str = url.substr(1);
  let strs = str.split("&");
  for(let i = 0; i < strs.length; i ++) {
    theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
  }
}
Direct theRequest.name, you can call up;
 
How to set parameters get behind #?
hash readable, writable,
写:window.location.hash = '.....'
读:window.location.hash
After obtaining the string, and then conducting analytical, analytical approach can refer to the article.
 
I hope this helps you
 
 

Guess you like

Origin www.cnblogs.com/wangqiao170/p/11272355.html