ÍøÂçѧԺ

w3pop.com :: ÍøÂçѧԺ :: HTML DOM :: DOM Window ¶ÔÏó

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

HTML DOM
DOM ½éÉÜ
HTML DOM ¾ÙÀý
DOM ²Î¿¼
DOM ÕªÒª
HTML DOM ʵÀý
DOM Anchor
DOM Applet
DOM Area
DOM Base ¶ÔÏó
DOM Basefont¶ÔÏó
DOM Body ¶ÔÏó
DOM Document ¶ÔÏ..
DOM ʼþ
DOM Form ¶ÔÏó
DOM Frame ¶ÔÏó
DOM Frameset ¶ÔÏ..
DOM History
DOM Iframe ¶ÔÏó
DOM Image ¶ÔÏó
HTML DOM Button¶..

DOM Window ¶ÔÏó


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ä¯ÀÀ:17205 :: ::

Window ¶ÔÏó

The Window object represents the browser window. A Window object is created automatically with every instance of a <body> or <frame> tag.
window¶ÔÏó´ú±íÁËä¯ÀÀÆ÷µÄ´°¿Ú¡£Ã¿µ±´°¿Úº¬ÓÐ<body>»òÊÇ<frame>±êÇ©¾Í»á×Ô¶¯½¨Á¢window¶ÔÏó

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Window ¶ÔÏ󼯺Ï

Collection
¼¯ºÏ
Description
ÃèÊö
IE F N W3C
frames[] Returns all named frames in the window
·µ»ØÔÚwindowÖÐËùÓÐÃüÃû¹ýµÄ¿ò¼Ü
3 1 2  

Window object¶ÔÏó

Object Description
ÃèÊö
IE  F N W3C
clientInformation Contains information about the browser
°üº¬ÓйØä¯ÀÀÆ÷µÄÐÅÏ¢
4      
clipboardData   5      
document This object can be used to access all elements in a page
Õâ¸ö¶ÔÏó¿ÉÒÔÓÃÀ´·ÃÎÊÔÚÒ³ÃæÖеÄËùÓÐÔªËØ
3      
event Represents the state of an event
ij¸öʼþµÄ״̬
4      
external   4      
history Contains the URLs the user has visited within a browser window
°üº¬Óû§ÔÚä¯ÀÀÆ÷´°¿ÚÖÐËùÓÐÒѾ­·ÃÎʹýµÄURL
3      
location Contains the current URL of the window
°üº¬Á˵±Ç°´°¿ÚµÄURL
3      
navigator Contains information about the client browser
°üº¬ÁËÓйؿͻ§¶Ëä¯ÀÀÆ÷µÄÐÅÏ¢
3      
screen Contains information about the client's display screen
°üº¬ÁËÓйؿͻ§¶ËÏÔʾÆÁÄ»µÄÐÅÏ¢
4      

Window ¶ÔÏóÊôÐÔ

Property
ÊôÐÔ
Description
ÃèÊö
IE  F N W3C
closed Returns a Boolean value that specifies whether the referenced window has been closed
»ñÈ¡ÒýÓô°¿ÚÊÇ·ñÒѹرա£
4 1 3  
defaultStatus Sets or returns the default text in the statusbar of the windows (will be displayed when the page loads)
ÉèÖûò»ñȡҪÔÚ´°¿Úµ×²¿µÄ״̬À¸ÉÏÏÔʾµÄȱʡÐÅÏ¢¡£
3 1 2  
dialogArguments Returns all variables passed into the modal dialog window
ÉèÖûò»ñÈ¡´«µÝ¸øÄ£Ê½¶Ô»°¿ò´°¿ÚµÄ±äÁ¿»ò±äÁ¿Êý×é¡£
4      
dialogHeight Sets or returns the height of the modal dialog window
ÉèÖûò»ñȡģʽ¶Ô»°¿òµÄ¸ß¶È¡£
4      
dialogLeft Sets or returns the left coordinates of the modal dialog window
ÉèÖûò»ñȡģʽ¶Ô»°¿òµÄ×ó×ø±ê¡£
4      
dialogTop Sets or returns the top coordinates of the modal dialog window
ÉèÖûò»ñȡģʽ¶Ô»°¿òµÄ¶¥×ø±ê¡£
4      
dialogWidth Sets or returns the width of the modal dialog window
ÉèÖûò»ñȡģʽ¶Ô»°¿òµÄ¿í¶È¡£
4      
frameElement Returns the frame/iframe object that is hosting the window in the parent document
»ñÈ¡ÔÚ¸¸ÎĵµÖÐÉú³É window µÄ frame »ò iframe ¶ÔÏó¡£
5      
length Sets or returns the number of frames in the window
ÉèÖûò»ñÈ¡¼¯ºÏÖжÔÏóµÄÊýÄ¿¡£
4 1 6  
name Sets or returns the name of the window
ÉèÖûò»ñÈ¡±íÃ÷´°¿ÚÃû³ÆµÄÖµ¡£
3 1 2  
offscreenBuffering Sets or returns a Boolean value that specifies whether the window is drawn offscreen before being visible to the user
ÉèÖûò»ñÈ¡¶ÔÏóÔÚ¶ÔÓû§¿É¼û֮ǰÊÇ·ñÒªÏÈÔÚÆÁÄ»Íâ»æÖÆ¡£
4      
opener Sets or returns a reference to the window that created the window
ÉèÖûò»ñÈ¡´´½¨µ±Ç°´°¿ÚµÄ´°¿ÚµÄÒýÓá£
4 1 3  
parent Returns the parent window
»ñÈ¡¶ÔÏó²ã´ÎÖеĸ¸´°¿Ú¡£
3 1 2  
returnValue Sets or returns the value returned from the modal dialog window
ÉèÖûò»ñÈ¡´Óģʽ¶Ô»°¿ò·µ»ØµÄÖµ¡£
4      
screenLeft Returns the x-coordinate of the upper left corner of the browser - relative to the upper left corner of the screen
»ñÈ¡ä¯ÀÀÆ÷¿Í»§Çø×óÉϽÇÏà¶ÔÓÚÆÁÄ»×óÉÏ½ÇµÄ x ×ø±ê¡£
5      
screenTop Returns the y-coordinate of the top corner of the browser - relative to the top corner of the screen
»ñÈ¡ä¯ÀÀÆ÷¿Í»§Çø×óÉϽÇÏà¶ÔÓÚÆÁÄ»×óÉÏ½ÇµÄ y ×ø±ê¡£
5      
self Returns a reference to the current window
»ñÈ¡¶Ôµ±Ç°´°¿Ú»ò¿ò¼ÜµÄÒýÓá£
3 1 2  
status Sets or returns the text in the statusbar of the window
ÉèÖûò»ñȡλÓÚ´°¿Úµ×²¿×´Ì¬À¸µÄÐÅÏ¢¡£
3 1 2  
top Returns the topmost ancestor window
»ñÈ¡×î¶¥²ãµÄ׿ÏÈ´°¿Ú¡£
3 1 2  

Window ¶ÔÏó·½·¨

Method
·½·¨
Description
ÃèÊö
IE F N W3C
alert() Displays an alert box with a specified message and an OK button
ÏÔʾ°üº¬ÓÉÓ¦ÓóÌÐò×Ô¶¨ÒåÏûÏ¢µÄ¶Ô»°¿ò¡£
3 1 2  
attachEvent("event",pointer)  ½«Ö¸¶¨º¯Êý°ó¶¨µ½Ê¼þ£¬ÒÔ±ãÿµ±¸ÃʼþÔÚ¶ÔÏóÉÏ´¥·¢Ê±¶¼µ÷Óøú¯Êý¡£ 5      
blur() Removes focus from the current window
Ê¹ÔªËØÊ§È¥½¹µã²¢´¥·¢ onblur ʼþ¡£
4 1 3  
clearInterval(ID) Cancels a timeout that is set with the setInterval() method
È¡ÏûÓÉsetInterval()½¨Á¢µÄ¼ä¸ôʼþ
4 1 4  
clearTimeout(ID) Cancels a timeout that is set with the setTimeout() method
È¡ÏûÓÉsetTimeout()·½·¨½¨Á¢µÄ¼ä¸ôʼþ
3 1 2  
close() Closes the current window
¹Ø±Õµ±Ç°ä¯ÀÀÆ÷´°¿Ú
3 1 2  
confirm() Displays a dialog box with a specified message and an OK and a Cancel button
ÏÔʾһ¸öÈ·È϶Ի°¿ò£¬ÆäÖаüº¬Ò»¸ö¿ÉÑ¡µÄÏûÏ¢ºÍÈ·¶¨È¡Ïû°´Å¥¡£
3 1 2  
createPopup() Creates a pop-up window
´´½¨µ¯³ö´°¿Ú¡£
5      
execScript("code", "lang")

Executes a specified script. The arguments can take the following values:
ÒÔ¸ø¶¨ÓïÑÔÖ´ÐÐÖ¸¶¨µÄ½Å±¾¡£

code Required. The code to be executed
±ØÑ¡¡£ËùÒªÖ´ÐеĴúÂë
lang Required. JScript | VBScript | JavaScript
±ØÑ¡¡£Ñ¡Ôñ´úÂëËùÊôÓïÑÔÀàÐÍ

4      
focus() Sets focus on the current window
¾Û½¹µ½µ±Ç°µÄ´°¿Ú
4 1 3  
moveBy(x,y) Moves the window a specified number of pixels in relation to its current co-ordinates
½«´°¿ÚµÄλÖÃÒÆ¶¯Ö¸¶¨ x ºÍ y Æ«ÒÆÖµ¡£
4 1 4  
moveTo(x,y) Moves the window's left and top edge to the specified co-ordinates
½«´°¿Ú×óÉÏ½ÇµÄÆÁĻλÖÃÒÆ¶¯µ½Ö¸¶¨µÄ x ºÍ y λÖá£
4 1 4  
navigate("URL") Loads the specified URL into the window
ÔÚµ±Ç°´°¿ÚÖÐ×°ÈëÖ¸¶¨ URL¡£
3      
open() Opens a new browser window
´ò¿ªÐ´°¿Ú²¢×°Èë¸ø¶¨ URL µÄÎĵµ¡£
3      
print() Prints the contents of the current window
´òÓ¡Óë´°¿Ú¹ØÁªµÄÎĵµ¡£
5 1 4  
prompt()

Displays a dialog box that prompts the user for input
ÏÔʾһ¸öÌáʾ¶Ô»°¿ò£¬ÆäÖдøÓÐÒ»ÌõÏûÏ¢ºÍÒ»¸öÊäÈë¿ò¡£

3 1 2  
resizeBy() Resizes the window by the specified pixels
¸ü¸Ä´°¿ÚµÄµ±Ç°Î»ÖÃËõ·ÅÖ¸¶¨µÄ x ºÍ y Æ«ÒÆÁ¿¡£
4      
resizeTo() Resizes the window to the specified width and height
½«´°¿ÚµÄ´óС¸ü¸ÄΪָ¶¨µÄ¿í¶ÈºÍ¸ß¶ÈÖµ¡£
4 1.5    
scroll() Deprecated. Use scrollTo() instead
½«´°¿Ú¹ö¶¯µ½×Ô×óÉÏ½ÇÆðÖ¸¶¨µÄ x ºÍ y Æ«ÒÆÁ¿¡£
4      
scrollBy() Scrolls the content by the specified number of pixels
½«´°¿Ú¹ö¶¯ x ºÍ y Æ«ÒÆÁ¿¡£
4 1 4  
scrollTo() Scrolls the content to the specified coordinates
½«´°¿Ú¹ö¶¯µ½Ö¸¶¨µÄ x ºÍ y Æ«ÒÆÁ¿¡£
4 1 4  
setActive()  ÉèÖöÔÏóΪµ±Ç°¶ÔÏó¶ø²»½«¶ÔÏóÖÃΪ½¹µã¡£ 5      
setInterval(code, millisec[, "lang"])

Calls a function / evaluate an expression every time a specified interval (in milliseconds) has been reached. The arguments can take the following values:
ÿ¾­¹ýÖ¸¶¨ºÁÃëÖµºó¼ÆËãÒ»¸ö±í´ïʽ¡£

code Required. A pointer to a function or the code to be executed
±ØÑ¡¡£Ö¸¶¨ÒªÖ´ÐÐÄĶδúÂë»òÊǺ¯Êý
millisec Required. The number of milliseconds
±ØÑ¡¡£ºÁÃëÊý
lang Optional. JScript | VBScript | JavaScript
¿ÉÑ¡¡£´úÂëÓïÑÔÀàÐÍ

4 1 4  
setTimeout()

Calls a function or evaluates an expression after a specified number of milliseconds
¾­¹ýÖ¸¶¨ºÁÃëÖµºó¼ÆËãÒ»¸ö±í´ïʽ¡£

3 1 2  
showHelp("URL"[, contextID])

Displays a Help file (must be of type .htm or .chm). When using this method, a second Help box appears when pressing F1 or when clicking Help on the menu bar. To prevent the default Help box from appearing set returnValue to false. The arguments can take the following values:
ÏÔʾ°ïÖúÎļþ¡£´Ë·½·¨¿ÉÓÃÓÚ Microsoft HTML °ïÖú¡£

URL Required. The URL of a Help file
±ØÑ¡¡£°ïÖúÎļþµÄURL
contextID Optional. A string or integer that specifies a context identifier in the Help file
¿ÉÑ¡¡£Ö¸¶¨°ïÖúÎļþ±êʶ·½ÃæµÄ×Ö·û´®»òÊÇÊý

4      
showModalDialog("URL"[, args, "list"]) Loads a URL in a modal dialog box. A modal dialog box retains focus while open. The user CANNOT switch windows until the dialog box is closed. The arguments can take the following values:
´´½¨Ò»¸öÏÔʾָ¶¨ HTML ÎĵµµÄģʽ¶Ô»°¿ò¡£

"URL" - Required. The URL of the document to display.
'URL' - ±ØÑ¡µÄ¡£ËùÏÔʾÎĵµµÄURL

args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object.
²ÎÊý - ¿ÉÑ¡¡£Ê²Ã´Ê±ºòÏÔʾURL.ʹÓÃÕâ¸ö²ÎÊýÀ´´«µÝÈκÎÀàÐ͵ÄÖµ£¬¿ÉÒÔÊÇÊý×éÖµ¡£¶Ô»°¿ò¿ÉÒÔ´Ówindow¶ÔÏóµÄdialogArgumentsÊôÐÔÖгé³öÖµ

"list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:
'list' - ¿ÉÑ¡¡£Ö¸¶¨¶Ô»°¿ò´°¿ÚµÄÐÞÊÎ,ÓÃÒ»ÖÖ»ò¶àÖÖÏÂÁеÄÖµ£¬Ã¿¸öÖµÓ÷ֺŸô¿ª¡£

dialogHeight : number the height* of the dialog window
¶Ô»°´°¿ÚµÄ¸ß¶È
dialogLeft : number the left position of the dialog window
×ó¶¨Î»
dialogTop : number the top position of the dialog window
É϶¨Î»
dialogWidth : number the width* of the dialog window
´°¿ÚµÄ¿í¶È
center : yes | no | 1 | 0 | on | off whether to center the dialog window within the desktop. Default is yes
ÊÇ·ñÏÔʾÔÚ×ÀÃæµÄÖмäλÖÃ
dialogHide : yes | no | 1 | 0 | on | off whether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
ÊÇ·ñÒþ²ØËùÊä³öµÄÄÚÈÝ£¬Ö»¶ÔÓÚ¿ÉÐŵijÌÐòËù´ò¿ªµÄ¶Ô»°¿ò²Å»áÓÐЧ¡£Ä¬ÈÏΪ no
edge : sunken | raised the edge style of the dialog window. Default is raised
¶Ô»°¿ò´°¿ÚµÄ±ßÔµÑùʽ
help : yes | no | 1 | 0 | on | off whether the dialog window displays the Help icon. Default is yes
ÊÇ·ñÏÔʾ°ïÖúͼ±ê
resizable : yes | no | 1 | 0 | on | off whether the dialog window is resizable. Default is no
¶Ô»°´°¿ÚµÄ´óСÊÇ·ñ¿É×öµ÷Õû¡£Ä¬ÈÏΪ·ñ
scroll : yes | no | 1 | 0 | on | off whether the dialog window displays scrollbars. Default is yes
ÊÇ·ñÏÔʾ¹ö¶¯Ìõ£¬Ä¬ÈÏΪÊÇ
status : yes | no | 1 | 0 | on | off whether the dialog window displays a status bar. Default is yes for untrusted dialog windows and no for trusted dialog windows
ÊÇ·ñÏÔʾµ×²¿µÄ״̬À¸
unadorned : yes | no | 1 | 0 | on | off whether the dialog window displays the border window chrome. Only available when a dialog window is opened from a trusted application. Default is no

4      
showModelessDialog("URL"[, args, "list"]) Loads a URL in a modeless dialog box. The modeless dialog box displays even when the user switches focus to another window (useful for menus and Help systems). The arguments can take the following values:
´´½¨Ò»¸öÏÔʾָ¶¨ HTML ÎĵµµÄ·Çģʽ¶Ô»°¿ò¡£

"URL" - Required. The URL of the document to display.

args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object.

"list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:

dialogHeight : number the height* of the dialog window
dialogLeft : number the left position of the dialog window
dialogTop : number the top position of the dialog window
dialogWidth : number the width* of the dialog window
center : yes | no | 1 | 0 | on | off whether to center the dialog window within the desktop. Default is yes
dialogHide : yes | no | 1 | 0 | on | off whether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
edge : sunken | raised the edge style of the dialog window. Default is raised
help : yes | no | 1 | 0 | on | off whether the dialog window displays the Help icon. Default is yes
resizable : yes | no | 1 | 0 | on | off whether the dialog window is resizable. Default is no
scroll : yes | no | 1 | 0 | on | off whether the dialog window displays scrollbars. Default is yes
status : yes | no | 1 | 0 | on | off whether the dialog window displays a status bar. Default is yes for untrusted dialog windows and no for trusted dialog windows
unadorned : yes | no | 1 | 0 | on | off whether the dialog window displays the border window chrome. Only available when a dialog window is opened from a trusted application. Default is no

5      

* The default unit of measure for dialogHeight and dialogWidth in IE4 is em; in IE5 it is px. Other values to use: cm, mm, in, pt, pc, or ex. For consistent results, use px! Note: The min. dialogHeight you can specify is 100px.
ÔÚIE4ÖÐdialogHeight ºÍdialogWidthµÄĬÈϵ¥Î»ÊÇem¡£ÔÚIE5Ϊpx¡£ÆäËüµÄµ¥Î»»á»ìÏý½á¹û£¬×îºÃÓÃpx£¡ ×¢Ò⣺dialogHeightµÄ×îСֵΪ100px

Window ¶ÔÏóʼþ

Óï·¨ window.event_name="someJavaScriptCode"

Event
ʼþ
Description
ÃèÊö
IE F N W3C
onBlur Executes some code when a Blur event occurs
ÔÚ¶ÔÏóʧȥÊäÈë½¹µãʱ´¥·¢¡£
  1 3  
onError Executes some code when an Error event occurs
µ±¶ÔÏó×°ÔØ¹ý³ÌÖз¢Éú´íÎóʱ´¥·¢¡£
  1 3  
onFocus Executes some code when a Focus event occurs
µ±¶ÔÏó»ñµÃ½¹µãʱ´¥·¢¡£
  1 3  
onLoad Executes some code when an Load event occurs
ÔÚä¯ÀÀÆ÷Íê³É¶ÔÏóµÄ×°ÔØºóÁ¢¼´´¥·¢¡£
  1 2  
onResize Executes some code when a Resize event occurs
µ±¶ÔÏóµÄ´óС½«Òª¸Ä±äʱ´¥·¢¡£
  1 4  
onUnload Executes some code when an Unload event occurs
ÔÚ¶ÔÏóÐ¶ÔØÇ°Á¢¼´´¥·¢¡£
  1 2  

ÆÀÂÛ (0) All