Browser Window

Window 对象

Window对象表示浏览器中打开的窗口。

如果文档包含框架(iframe或iframe标签),浏览器会被html文档创建一个window对象,并为每个框架创建一个额外的window对象。

注释:没有应用于window对象的公开标准,不过所有浏览器度支持该对象

window对象集合

iframes【】 返回窗口中所有命名的框架。该集合是window对象的数组,每个window对象在窗口中含有一个框架或<iframe>。属性frames.length存放数组iframes[]中含有的元素个数。注意,iframes【】数组中引用的框架可能还包括框架,它们自己也具有frames【】数组。

window对象属性

closed 返回窗口是否已被关闭

defaultStatus 设置或返回窗口状态栏中的默认文本。

document 对document对象的只读引用。

history 对history对象只读引用

innerheight 返回窗口的文档显示区高度

innerwidth 返回窗口的文档显示区跨度

length 设置或返回窗口中的框架数量

location 用于窗口或框架的Location对象

name 设置或返回窗口的名称

Navigator 对Navigator对象的只读引用

opener 返回创建此窗口的窗口引用

outerheight 返回窗口的外部高度

outerwidth 返回窗口的外部宽度

pageXOffset 设置或返回当前页面相对于窗口显示区左上角的X位置

pageYOffset 设置或返回当前页面相对于窗口显示区左上角的Y位置

parent 返回父窗口

Screen 对screen对象的只读引用

self 返回对当前窗口的引用。等价于window属性

status 设置窗口状态栏的文本

top 返回最顶层的先辈窗口

window window属性等价于self属性,它包含了对窗口自身的引用

screenLeft

screenTop

screenX

screenY   以上四个都是只读整数。声明了窗口左上角在屏幕上的x坐标和y坐标。

Window对象方法

alert()显示带有有一段消息和一个确认按钮的警告框。

blur()把键盘焦点从顶层窗口移开。

clearInterval()取消setInterval()设置的timeout

clearTimeout()取消setTimeout()方法设置的timeout

close()关闭浏览器窗口

confirm()显示带有一段消息以及确认按钮和取消按钮的对话框

createPopup()创建一个pop-up窗口

focus()把键盘焦点给予一个窗口

moveBy()可相对窗口的当前坐标把它移动到指定的像素

moveTo()把窗口的左上角移动到一个指定的坐标

open()打开一个新的浏览器窗口或查找一个已命名的窗口

print()打印当前窗口的内容

prompt()显示可提示用户输入的对话框

resizeBy()按照指定的像素调整窗口的大小

resizeTo()把窗口的大小调整到指定的宽度和高度

scrollBy()按照指定像素值来滚动内容

scrollTo()把内容滚动到指定的坐标

setInterval()按照指定的周期(以毫秒计)来调用函数或计算表达式

setTimeout()在指定的毫秒数后调用或计算表达式

window对象描述

window对象表示一个浏览器窗口或一个框架。在客户端javascript中,window对象是全局对象,所有的表达式都在当前的环境中计算。也就是说,要引用当前窗口根本不需要特殊的语法,可以把那个窗口的属性作为全局变量来使用。例如,可以只写document,而不必写window.document。

同样,可以把当前窗口对象的方法当作函数来使用,如只写alert(),而不必写window.alert()

除了上面列出的属性和方法,window属性和self属性引用的都是它自己。当你想明确引用当前窗口,而不仅仅是隐式地引用它时,可以使用这两个属性。除了这两个属性之外。parent属性,top属性以及frame[]数组都引用了当前window对象相关的其他window对象。

要用引用窗口中的一个框架,可以使用如下语法

frame[i] //当前窗口

self.frame【i】//当前窗口的框架

w.frame[i]  //窗口w的框架

时间: 2024-08-30 17:40:41

Browser Window的相关文章

UI Framework-1: Browser Window

Browser Window The Chromium browser window is represented by several objects, some of which are included in this diagram: Frame The frame is the portion of the browser window that includes the title bar, sizing borders, and other areas traditionally

Make div 100% height of browser window/设置div等于浏览器的高度

Viewport-Percentage (or Viewport-Relative) Lengths Viewport-Percentage Lengths: The viewport-percentage lengths are relative to the size of the initial containing block. When the height or width of the initial containing block is changed, they are sc

Browser environment

目录1.The global structur 2.Summary The browser provides us with a hierarchy of objects which we can use to control and access various information about time, screen, page, elements on a page etc. The global structure The browser provides access to a l

Introduction into browser events

Ilya Kantor Assigning event handlers Using a attribute of HTML-tag When to use this method The element is this Using a DOM-object property When to use Special methods Microsoft solution Handlers assignment by W3C standard Handlers order A cross-brows

Window Relationships and Frames

If a page contains frames, each frame has its own window object and is stored in the frames collection. Within the frames collection, the window objects are indexed both by number and by the name of the frame. The top object always points to the very

The window object

At the core of the BOM is the window object, which represents an instance of the browser. The window object serves a dual purpose in browsers, acting as the JavaScript interface to the browser window and the ECMAScript Global object. This means that

Browser security standards via access control

A computing system is operable to contain a security module within an operating system. This security module may then act to monitor?access?requests by a web browser and apply?mandatory?access?control?security policies to such requests. It will be ap

Designing CSS Layouts With Flexbox Is As Easy As Pie

This article is an updated excerpt of the chapter "Restyle, Recode, Reimagine With CSS3″ from our Smashing Book #3, written by Lea Verou and David Storey. - Ed. Flexible box layout (or flexbox) is a new box model optimized for UI layout. As one of th

使用 electron 实现类似新版 QQ 的登录界面效果(阴影、背景动画、窗体3D翻转)

上文<使用 VS2017 和 js 进行桌面程序开发 - electron 之 Hello Word>介绍了如何使用 VS2017 开发 electron 桌面程序,今天来点有看头的,但是没什么技术含量,囧~~ 现在什么都讲究追赶潮流,觉得 QQ 登录窗口做的效果不错,既然刚学习 electron ,那么就用 electron 模仿一下.其实主要用到的就是 CSS3 的效果:边框圆角.阴影,3D变换.对,就这么简单.先上效果: 下面是关键代码: app.js 'use strict'; con