JavaScript encodeURI() function
- 上一页 decodeURIComponent()
- 下一页 encodeURIComponent()
- 返回上一层 JavaScript 全局 参考手册
Definition and usage
encodeURI()
Function used to encode URI.
This function encodes special characters except: , / ? : @ & = + $ # (use encodeURIComponent() to encode these characters).
Tip:Please use decodeURI()
Function to decode the URI that has been encoded.
Example
Encode URI:
var uri = "my test.asp?name=ståle&car=saab"; var res = encodeURI(uri);
Syntax
encodeURI(uri)
Parameter value
Parameter | Description |
---|---|
uri | Required. The URI to be encoded. |
Technical details
Return value: | A string representing the encoded URI. |
---|
Browser supports
函数 | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
encodeURI() | 支持 | 支持 | 支持 | 支持 | 支持 |
- 上一页 decodeURIComponent()
- 下一页 encodeURIComponent()
- 返回上一层 JavaScript 全局 参考手册