var uri="http://w3cschool.cc/my test.php?name=ståle&car=saab";
var uri_encode=encodeURIComponent(uri);
document.write(uri_encode);
document.write("<br>");
document.write(decodeURIComponent(uri_encode));
以上实例输出结果:
http%3A%2F%2Fw3school.cc%2Fmy%20test.php%3Fname%3Dst%C3%A5le%26car%3Dsaab
http://w3schools.com/my test.asp?name=ståle&car=saab
本文提供了一个关于如何使用JavaScript的encodeURIComponent和decodeURIComponent函数来编码和解码URL的示例。通过具体的代码演示了字符串被转换成适用于URL的格式的过程,并展示了如何将编码后的URL再还原为原始字符串。
1013

被折叠的 条评论
为什么被折叠?



