关于javascript:BOMBrower-Object-Model-浏览器对象模型

一、window对象的罕用属性

1、创立正告对话框 alert()
2、创立确认对话框 confirm()
3、创立信息提醒对话框 prompt()
4、关上指定窗口
   window.open(url, name, spec)
   url:能够使残缺的地址,也能够是相对路径
   name:窗口打开方式(_blank、_self、_parent、_top)
        _blank: 新开一个窗口
        _self: 以后窗口显示
        _parent:在以后窗口的父窗口显示
        _top:在顶层窗口显示

二、定时器

1、间歇定时器
window.onload = function(){
    let num = 10
    let oSpan = document.getElementById('day')
    let timer = setInterval(function(){
        oSpan.innerHTML = --num
        if (num == 0) {
            clearInterval(timer)
        }
    }, 1000)
}

2、延时定时器

let oSpan = document.getElementsByTagName('span')[0]
let timer = null
let num = 10

function count(){
    oSpan.innerHTML = --num
    timer = setTimeout(count, 1000)
    if (num == 0) {
        clearTimeout(timer)
    }
}

timer = setTimeout(count, 1000)

三、navigator对象办法
navigator.userAgent 判断浏览器的类型
navigator.cookieEnabled 判断浏览器中是否启用cookie

四、location对象

1、加载新文档      window.location.assign(url)
2、从新加载以后文档  window.location.reload()
3、用新的文档替换以后文档  window.location.replace()

五、history对象

1、back(): 加载history列表中的前一个url
2、forward(): 加载history列表中的下一个url
3、go(number): number是要拜访的url在history的url列表中的绝对地位
4、pushState(state,title,url): 增加指定的url到历史记录中,并且刷新将地址栏中的 
                               网址更新为url
5、replaceState(state,title,url): 应用指定的url替换以后历史记录,并且无需刷新浏 
                               览器就会将地址栏中的网址更新为url

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理