首页 > 其他 > 详细

DOM 对象

时间:2020-04-14 10:26:27      阅读:53      评论:0      收藏:0      [点我收藏+]
    <script>
        // location对象  对应地址栏
        //  属于window对象
        // console.log( location );
        // console.log( window.location );
        
        // 关注点2个
        // href属性

        // 获取href属性值 ==> 页面完整地址
        console.log( location.href );

        // 赋值 ==> 跳转页面
        // location.href = "xxxx";


        // reload方法  ==> 刷新页面
        // location.reload();
        // location.href = "";
    </script>

 

自动跳转功能

<body>

    <a href="http://www.itcast12334222.cn">注册成功,3秒后跳转到首页</a>

    <script>
        // 自动跳转页面
        // 倒计时

        var link = document.querySelector("a");
        var count = 3;

        var timerId = setInterval(function () {
            count--;

            // 修改a链接的内容
            link.innerText = "注册成功,"+ count +"秒后跳转到首页";

            // 判断
            if(count === 0){
                // 倒计时到了 ==> 跳转页面
                location.href = link.href;

                // 清除定时器 (建议)
                clearInterval(timerId);
            }
        }, 1000)
    </script>
</body>

 

BOM其它对象

<body>

    <a href="01-放大镜/index.html">去看放大镜案例</a>

    <script>
        // navigator 对象 浏览器的版本信息
        // userAgent 属性
        // console.log(navigator.userAgent);


        // history 对象 浏览器的浏览的历史记录
        // history.back() 后退一个历史记录
        // history.forward() 前进一个历史记录
        // history.go(数值) 指定历史记录
        // history.go(1) 指定前进历史记录 ==> history.forward()
        // history.go(-1) 指定后退历史记录 ==> history.back()
        // history.go(0) 刷新页面

        // 刷新页面
        //  1. location.reload()
        //  2. location.href = ""
        //  3. history.go(0)
    </script>
</body>

 

DOM 对象

原文:https://www.cnblogs.com/DuYueJin/p/12695569.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!