JavaScript APIs are inherently Base64, so we can easily encode and decode them.
var encodedata = Window.btoa ("name=xiaoming&age=10")//code
var decodedata = Window.atob (encodedata)//decoding.
Here is a concrete example of how to transcode the parameters in the URL and get the decoded parameters
If the URL to jump = "stu_info.html?name=xiaoming&age=10"
transcoding: url = "stu_info.html?" +window.btoa ("name=xiaoming&age=10");
Jump: window.open (URL) or window.locaton.href = URL;
Decoding: We first get the parameter list from the URL when decoding,
We can use var paramsstring = Window.location.search to get the contents of the URL (the query part of the URL), i.e. "? name=xiaoming&age=10";
Then remove the paramsstring = paramsstring.substring (1)//"name=xiaoming&age=10"
Remove & paramsstring = Paramsstring.split ("&");//["Name=xiaoming", "age=10"]
It is important to note that the encoding method in this WINDOW.BTOA does not directly work on Unicode strings. Only Ascci strings or binary data can be converted to BASE64 encoded strings. If you want to encode Unicode characters, you can do the following conversions.
var encodedata = Window.btoa (Window.encodeuricomponent ("Name= xiaoming &age=10")//code
var decodedata = window.decodeuricomponent (Window.atob (Encodedata))//decoding.
JavaScript makes simple cryptographic processing of parameters in URLs