w3pop.com :: ÍøÂçѧԺ :: HTML DOM :: DOM 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).
| Collection ¼¯ºÏ |
Description ÃèÊö |
IE | F | N | W3C |
|---|---|---|---|---|---|
| frames[] | Returns all named frames in the window ·µ»ØÔÚwindowÖÐËùÓÐÃüÃû¹ýµÄ¿ò¼Ü |
3 | 1 | 2 |
| 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 |
| 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 |
| 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:
|
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:
|
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:
|
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. 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:
|
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:
|
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.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