您的位置:首页 > Web前端 > JavaScript

js实用api收藏

2014-04-08 22:55 183 查看
1、encodeURI() 函数可把字符串作为 URI 进行编码。

2、decodeURI() 函数可对 encodeURI() 函数编码过的 URI 进行解码。

3、decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码。

4、encodeURIComponent() 函数可把字符串作为 URI 组件进行编码。

5、unescape() 函数可对通过 escape() 编码的字符串进行解码。

6、escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串。

7、window.location.href

      可以获得整个URL字符串(在浏览器中就是完整的地址栏)。

8、location.search

     返回URL中的查询字符串部分

<script>  

function GetRequest()  

{  

var url = location.search; //获取url中"?"符后的字串  

var theRequest = new Object();  

if(url.indexOf("?") != -1)  

{  

  var str = url.substr(1);  

  var  strs = str.split("&");  

  for(var i = 0; i < strs.length; i ++)  

    {  

     theRequest[strs[i].split("=")[0]]=strs[i].split("=")[1];  

    }  

}  

return theRequest;  

}  

</script>

如果想深入对上面的函数和变量的理解,可以访问以下地址:http://www.w3school.com.cn/js/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  js api