locatin

 1 //location对象
 2 //初始url:http://www.wrox.com/WileyCDA;
 3 //将URL修改为:http://www.wrox.com/WileyCDA/#section1
 4 location.hash="#section1"
 5 //将URL修改为:http://www.wrox.com/WileyCDA/?q=javascript
 6 location.search="?q=javascript"
 7 //将URL修改为:http://www.yahoo.com/WileyCDA/
 8 location.hostname="www.yahoo.com"
 9 //将URL修改为:http://www.yahoo.com/mydir
10 location.pathname="mydir"
11 location.post=8080;
12 location.assign("http://www.wrox.com");
13 // 等同于:
14 //window.location="http://www.wrox.com"
15 //  location.href="http://www.wrox.com"
16 location.replace("http://www.wrox.com")//不会产生历史记录

 

posted @ 2018-06-02 17:40  前端极客  阅读(407)  评论(0编辑  收藏  举报