location对象

location表示当前页面的Url信息

location.href; // http://www.example.com:8080/path/index.html?a=1&b=2#TOP

location.protocol; // 'http'

location.host; // 'www.example.com'

location.port; // '8080'

location.pathname; // '/path/index.html'

location.search; // '?a=1&b=2'

location.hash; // 'TOP'

页面切换location.assign('/')
页面刷新location.reload()

location.assign('https://www.baidu.com');
posted @ 2018-03-29 14:03  Kaso基佬康  阅读(81)  评论(0编辑  收藏  举报