When href is needed to pass parameters, and the parameters are in Chinese, garbled characters will appear. The simplest method is: The passed value is first encrypted with escape() , and then decrypted with unescape() on the value access page. It has been tested and is effective. I checked online and found that urlencode can be used for encryption and urldecode can be used for decryption. Um... what is the difference between the two? I just checked and sorted it out, source (http://www.cnblogs.com/glory-jzx/archive/2013/06/14/3135580.html): js involves 3 functions to encode text : escape, encodeURI, encodeURIComponent, and 3 corresponding decoding functions: unescape, decodeURI, decodeURIComponent 1. When passing parameters, you need to use encodeURIComponent so that the combined URL will not be truncated by special characters such as #. >2. When redirecting URL, you can use encodeURI as a whole 5. The most commonly used one should be encodeURIComponent , which converts special characters such as Chinese and Korean into utf-8 URL encoding. Therefore, if you need to use encodeURIComponent to pass parameters to the background, the background decoding needs to support utf-8 (the encoding method in the form is the same as the encoding method of the current page) 6. No encoding: There are 69 escape characters: *, +, -, ., /, @, _, 0-9, az, AZ What is the difference between escape() and encodeURI()? escape() method: encodeURI() Method encodeURIComponent() method: [When is it appropriate to use which method?] I have only used escape, so this is for reference only. The above article about the Chinese garbled code problem in a href parameter passing is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. Original URL: http://www.cnblogs.com/zhangym118/archive/2016/07/05/5644915.html |
<<: Vue+Echart bar chart realizes epidemic data statistics
>>: HTML imitates Baidu Encyclopedia navigation drop-down menu function
General mobile phone style: @media all and (orien...
Recorded the installation tutorial of mysql 5.7.1...
title: vue uses vue-meta-info to set the title an...
Table of contents Application Scenario Ideas Proj...
When I was helping someone adjust the code today,...
Using Dockerfile allows users to create custom im...
Table of contents cause reason Introduction to NP...
Preface In WEB development, we often involve cros...
Table of contents Brief summary At noon today, th...
The team replaced the new frame. All new business...
type is the control used for input and output in t...
Learn a jQuery plugin every day - floating menu, ...
Overview The fundamental difference between async...
Introduction In orm frameworks, such as hibernate...
There are very complex HTML structures in web pag...