1. escape() cannot be used directly for URL encoding. Its real function is to return a character's Unicode-encoded value. For example, the return result of "Spring Festival" is %u6625%u8282. Escape() is incorrect "+" encoding, and it is mainly used for man encoding, and it is no longer recommended to use it.
2. encodeURI() is a function that is really used to encode URLs in JavaScript. Encode the entire URL address, but the symbol ";/?:@&=+$,#" with special meanings is not encoded. The corresponding decoding function is decodeURI().
3. encodeURIComponent() can encode these special characters ";/?:@&=+$,#". The corresponding decoding function decodeURIComponent(). If you want to pass a URL with the & symbol, use encodeURIComponent()
In summary , once you need to pass a "+" symbol in the foreground to the background. Unexpectedly, it will be automatically decoded into a space in the background. Finally, I found that the background corresponding to "+" in the url is a space. The space will automatically become + in the foreground in the foreground, so you must start encoding "+". If you are sure that there may be "+" in the parameter, first encode it to encode URIComponent() before passing the value. When you go to the background to get the value, it will become "+".
The above detailed explanation of several encoding methods of JavaScript url is all the content shared by the editor. I hope it can give you a reference and I hope you will support Wulin.com more.