多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
在URL或URI中,有一些字符是具有特殊含义的。如果我们想“转义”这些字符,就可以去调用函数encodeURI()或encodeURIComponent()。 前者会返回一个可用的URL,而后者则会认为我们所传递的仅仅是URL的一部分。 例如: ``` >>> var url = 'http://find35.com/index.php?s =/Home/Article/index/id/191.html'; undefined >>> encodeURI(url); http://find35.com/index.php?s%20=/Home/Article/index/id/191.html >>> encodeURIComponent(url); http%3A%2F%2Ffind35.com%2Findex.php%3Fs%20%3D%2FHome%2FArticle%2Findex%2Fid%2F191.html ``` encodeURI()对应的解码是decodeURI() encodeURIComponent()对应的解码是decodeURIComponent()