I now need to use the parameter transfer between two html pages, in a.html
becomes a percent sign or something in b.html, and everything is messed up. Is there any way to prevent the Chinese from being garbled? Waiting online! !
Convert Chinese using urlencode first
Convert Chinese using urlencode first
How to convert, can you give me An example?
<script> <br> document.write("<a href='b.html?addr=" encodeURIComponent("Shanghai City") "&b=" encodeURIComponent("Boxia Road") "'>aaaaaa</a>"); <br> </script>
In js, escape("XXX") is used for character encoding, and unescape("XXX") is used for decoding.
The method on the 4th floor is no longer recommended. Use the method on the 3rd floor.
<script> <br> document.write("<a href='b.html?addr=" encodeURIComponent ("Shanghai City") "&b=" encodeURIComponent("Boxia Road") "'>aaaaaa</a>"); <br> </script>
Go to another page When the second page receives the values, do they all become %%%? ?
var url=document.location.href;
var sub1=url.substring(url.indexOf("=") 1,url.indexOf("&"));
var sub2 =url.substring(url.lastIndexOf("=") 1);
alert("sub1:" sub1 " sub2:" sub2);
Both sub1 and sub2 are 100% consistent, What I want is that it can display Chinese
I already know, just use decodeURIComponent(sub1) to decode it, thank you very much 3lz for the example! ! !