当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JavaScript encodeURIComponent(
The encodeURI() function encodes a string as a component of a URI.
encodeURI()方法将字符串转换成URI的一个元素
encodeURIComponent(URIstring) |
Parameter 参数 | Description 注释 |
---|---|
URIstring URI字符串 | Required. The URI to be encoded 必选项。所要转换的URI |
Tip: Use the decodeURIComponent() function to decode URIs encoded with encodeURIComponent().
提示:用decodeURIComponent()方法编译URIs,反编译用encodeURIComponent()
In this example we use encodeURIComponent() to encode URIs:
在下面的例子中,我们将演示用encodeURIComponent()来编译URIs:
<script type="text/javascript"> document.write(encodeURIComponent("http://www.ruanchen.com")) </script> |
The output of the code above will be:
输出结果为:
http%3A%2F%2Fwww.ruanchen.com |
encodeURIComponent()
How to use encodeURIComponent() to encode different URIs.
如何用encodeURIComponent()来编译不同的URIs