encodeURI()、decodeURI()及encodeURIComponent()、decodeURIComponent()区别

上代码:

var test1="http://www.w3school.com.cn/My first/"

document.write(encodeURI(test1)+ "<br />")
document.write(decodeURI(test1))

//输出
http://www.w3school.com.cn/My%20first/
http://www.w3school.com.cn/My first/


document.write(encodeURIComponent(test1)+ "<br />")
document.write(decodeURIComponent(test1))

//输出
http%3A%2F%2Fwww.w3school.com.cn%2FMy%20first%2F
http://www.w3school.com.cn/My first/
原文地址:https://www.cnblogs.com/damade/p/4894917.html