日期:2014-05-16  浏览次数:20410 次

JS encodeURI()和encodeURIComponent()区别

encodeURI():对URI中的特殊字符不进行编码(:/?)

encodeURIComponent():所有非标准字符进行编码

?

var str = "http://www.baidu.com/";
alert(encodeURI(str));//http://www.baidu.com/
//http%3A%2F%2Fwww.baidu.com%2F
alert(encodeURIComponent(str));

?