Home  >  Article  >  Web Front-end  >  Solution to the error that js parameters are affected by special characters_javascript skills

Solution to the error that js parameters are affected by special characters_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:19:33997browse

When special characters like `~!@#$%^&*()_ -=[]{}|;':”,./? are used as parameters, if they are not processed, the product will pass the parameters Error.

Workaround:

encodeURI method
encodes a text string into a valid Uniform Resource Identifier (URI). >encodeURI(URIString)

The required URIString parameter represents an encoded URI.


Description
The encodeURI method returns an encoded URI. If you pass the encoding result to decodeURI, the original string is returned. The encodeURI method does not encode the following characters: ":", "/", ";" and "?". Use the encodeURIComponent method for these characters. Encode.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn