2008年7月9日 星期三

[javascript] encodeURIComponent 與 decodeURIComponent 函數


document.write(encodeURIComponent("http://www.w3schools.com"));
document.write("
");
document.write(encodeURIComponent("http://www.w3schools.com/p 1/"));
document.write("
");
document.write(encodeURIComponent(",/?:@&=+$#"));

var test1="http://www.w3schools.com/js/";

document.write(encodeURIComponent(test1)+ "
");
document.write(decodeURIComponent(test1));


結果如下:
http%3A%2F%2Fwww.w3schools.com
http%3A%2F%2Fwww.w3schools.com%2Fp%201%2F
%2C%2F%3F%3A%40%26%3D%2B%24%23

http%3A%2F%2Fwww.w3schools.com%2Fjs%2F
http://www.w3schools.com/js/

【下列文章您可能也有興趣】

沒有留言: