当前位置:Gxlcms > html代码 > HTMLDOMWindow对象_html/css_WEB-ITnose

HTMLDOMWindow对象_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:9人阅读

  本篇主要介绍HTML DOM Window对象的属性和方法。

目录

1.介绍:描述HTML DOM Window对象。

2.属性:介绍window对象的属性。如:对Console、Document、History、Location和Navigator对象的引用。

3.方法:介绍window对象的方法。如:获取焦点、改变滚动条、设置定时器等等。

1. 介绍

Window对象表示浏览器打开的窗口、标签或者框架(若当前页面里包含多个iframe,会为每个iframe创建Window对象)。

Window对象不会被实例化,调用属性和方法都作为window的静态成员。

在调用Window对象的成员时,可以省略前面的window。如:window.alert() 可写成 alert() 。

2. 属性

readonly ApplicationCache applicationCache :返回窗口的应用缓存对象。

readonly boolean closed :返回窗口是否已经关闭。

readonly Console console :返回对Consol对象的引用,对浏览器控制台进行操作。

readonly int devicePixelRatio :返回设备像素比,即当前显示器的物理像素和设备独立像素(dip)的比例。

readonly Document document :返回当前窗口的Document对象。

readonly Element frameElement :若当前window处于一个