In the encodeURIComponent javascript () and the encodeURI () difference

Introduction: js only a few global functions, there are two global functions can be used to encode the url string.

一、encodeURIComponent()

The escape URI punctuation used to separate the various parts, that is, you can encode ":" "//" characters, "?" And other logo.

 

二、encodeURI()

After testing, it can encode only the url of  Chinese characters

 

 summary:

  1, because encodeURIComponent () encoding relatively large range, if it is passed around the end of the url (not access or jump), it is recommended to use this!

  2, if the front-end url to access the back-end, and carry the parameters of the text, it is recommended to use encodeURI (), because it does not affect the jump at the same time, be able to carry the argument to the backend! !

Guess you like

Origin www.cnblogs.com/teamemory/p/11989809.html