location对象属性
location对象属性 返回值
location.href 获取或者设置整个URL
location.host 返回主机(域名)www.baidu.com
location.port 返回端口号,如果未写返回空字符串
location.pathname 返回路径
location.search 返回参数
location.hash 返回片段 #后面内容常见于链接 锚点
5秒后跳转页面:
<body>
    <button>点击</button>
    <div></div>
    <script>
        var btn = document.querySelector('button');
        var div = document.querySelector('div');
        var timer = 5;
        setInterval(function() {
            if (timer == 0) {
                location.href = 'https://www.baidu.com/';
            } else {
                div.innerHTML = '您将在' + timer + '秒钟之后跳转到首页';
                timer--;
            }
 
        }, 1000);
    </script>
</body>









