美文网首页
encodeURI和encodeURIComponent

encodeURI和encodeURIComponent

作者: Thomas赵骐 | 来源:发表于2019-04-09 15:13 被阅读0次

最常用的encodeURI和encodeURIComponent

对URL编码是常见的事,所以这两个方法应该是实际中要特别注意的。

它们都是编码URL,唯一区别就是编码的字符范围,其中

encodeURI方法不会对下列字符编码ASCII字母、数字、~!@#$&*()=:/,;?+'

encodeURIComponent方法不会对下列字符编码ASCII字母、数字、~!*()'

所以encodeURIComponent比encodeURI编码的范围更大。

实际例子来说,encodeURIComponent会把 http://  编码成  http%3A%2F%2F 而encodeURI却不会。

相关文章

网友评论

      本文标题:encodeURI和encodeURIComponent

      本文链接:https://www.haomeiwen.com/subject/rhntpqtx.html