escaping special character in a url

前端 未结 2 1087
予麋鹿
予麋鹿 2020-12-06 07:53

I am using a url to open a html page, and i am sending data in querystring withe the page url.

For example: abc.html?firstParameter=firstvalue&seconedParam

2条回答
  •  攒了一身酷
    2020-12-06 08:03

    You have 3 options:

    escape() will not encode: @*/+
    
    encodeURI() will not encode: ~!@#$&*()=:/,;?+'
    
    encodeURIComponent() will not encode: ~!*()'
    

    But in your case, if you want to pass a url into a GET parameter of other page, you should use escape or encodeURIComponent, but not encodeURI.

提交回复
热议问题