BOM

广义的JS包含三部分:

BOM为浏览器窗口对象的一组API.

BOM结构图

BOM属性:

可以通过navigator.userAgent判断当前设备运行在什么浏览器上,其包含信息:

location:浏览器定位和导航

location最重要属性为href,,它代表浏览器访问当前资源的完整路径,可以通过修改url属性进行浏览器跳转。

location属性的方法:

assign(url) 载入新的 url,记录浏览记录

replace(url) 载入新的 url 不记录浏览记录

reload() 重新载入当前页

history属性:

浏览器当前窗口的浏览历史,其包含的方法有:

back()后退

forward()前进
go()正数向前,负数向后

Screen属性:屏幕信息

Window对象(BOM)下的方法:

打开或关闭窗口:open()/close()

var w = window.open('subwindow.html', 'subwin', 'width=300, height=300, status=yes, resizable=yes');
// 既可关闭窗口
w.close();

Window对象事件

results matching ""

    No results matching ""