The realization method of JS filter URL parameter special character

Source: Internet
Author: User

This article is mainly on the JS filter URL parameters of the implementation of special characters to carry out a detailed analysis of the introduction, the need for friends can come to the reference, I hope to help you

In the URL pass parameter, there are some special characters, these symbols in the URL is not directly passed, if you want to pass these special symbols in the URL, then use their code. The following table lists some URL special symbols and encoded hexadecimal values of 1. + the + number in the URL indicates the space%2b 2. Spaces in a space URL can be%20 3 with the + sign or code. /delimited directory and subdirectory%2f 4. ? Separate the actual URL and parameter%3f 5. % Specifies special character%25 6. # indicates bookmark%23 7. & separator between the parameters specified in the URL%26 8. = The value of the specified parameter in the URL%3d Workaround: Replace () method if directly with Str.replace ("-", "!") Only the first matching character will be replaced. and Str.replace (/-/g, "!")   You can replace all the matching characters (G is the global flag). Replacement character variables in replace () JS are as follows: Data2=data2.replace (/%/g, "%25"); Data2=data2.replace (/#/g, "%23"); Data2=data2.replace (/&/g, "%26");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.