window.frames[i] in Javascript
By: David Flanagan in Javascript Tutorials on 2008-08-31
The Window object defines the following properties. Non-portable, browser-specific properties are listed separately after this list. Note that the Window object is the Global object for client-side JavaScript; therefore the Window object also has the properties listed on the Global reference page.
- closed
-
A read-only boolean value that specifies whether the window has been closed.
- defaultStatus
-
A read/write string that specifies a persistent message to appear in the status line whenever the browser is not displaying another message.
- document
-
A read-only reference to the Document object contained in this window or frame. See Document.
- frames[ ]
-
An array of Window objects, one for each frame contained within the this window. Note that frames referenced by the frames[ ] array may themselves contain frames and may have a frames[ ] array of their own.
- history
-
A read-only reference to the History object of this window or frame. See History.
- length
-
Specifies the number of frames contained in this window or frame. Same as frames.length.
- location
-
The Location object for this window or frame. See Location. This property has special behavior: if you assign a URL string to it, the browser loads and displays that URL.
- name
-
A string that contains the name of the window or frame. The name is specified with the Window.open() method, or with the name attribute of a <frame> tag. Read-only in JS 1.0; read/write in JS 1.1.
- navigator
-
A read-only reference to the Navigator object, which provides version and configuration information about the web browser. See Navigator.
- opener
-
A read/write reference to the Window that opened this window. JS 1.1.
- parent
-
A read-only reference to the Window object that contains this window or frame. If this window is a top-level window, parent refers to the window itself.
- screen
-
A read-only reference to the Screen object that specifies information about the screen the browser is running on. See Screen. JS 1.2.
- self
-
A read-only reference to this window itself. This is a synonym for the window property.
- status
-
A read/write string that can be set to display a transient message in the browser's status line.
- top
-
A read-only reference to the the top-level window that contains this window. If this window is a top-level window, top refers to the window itself.
- window
-
The window property is identical to the self property; it contains a reference to this window.
Netscape 4 Properties
- innerHeight, innerWidth
-
Read/write properties that specify the height and width, in pixels, of the document display area of this window. These dimensions do not include the height of the menubar, toolbars, scrollbars, and so on.
- outerHeight, outerWidth
-
Read/write integers that specify the total height and width, in pixels, of the window. These dimensions include the height and width of the menubar, toolbars, scrollbars, window borders, and so on.
- pageXOffset, pageYOffset
-
Read-only integers that specify the number of pixels that the current document has been scrolled to the right (pageXOffset) and down (pageYOffset).
- screenX, screenY
-
Read-only integers that specify the X and Y-coordinates of the upper-left corner of the window on the screen. If this window is a frame, these properties specify the X and Y-coordinates of the top-level window that contains the frame.
IE 4 Properties
- clientInformation
-
An IE-specific synonym for the navigator property. Refers to the Navigator object.
- event
-
The event property refers to an Event object that contains the details of the most recent event to occur within this window. In the IE event model, the Event object is not passed as an argument to the event handler, and is instead assigned to this property.
Methods
The Window object has the following portable methods. Since the Window object is the Global object in client-side JavaScript, it also defines the methods listed on the Global reference page.
- alert( message)
-
Displays message in a dialog box. Returns nothing. JS 1.0.
- blur()
-
Yields the keyboard focus and returns nothing. JS 1.1.
- clearInterval( intervalId)
-
Cancels the periodic execution of code specified by intervalId. See setInterval(). Returns nothing. JS 1.2.
- clearTimeout( timeoutId)
-
Cancels the pending timeout specified by timeoutId. See setTimeout(). Returns nothing. JS 1.0.
- close()
-
Closes a window and returns nothing. JS 1.0.
- confirm( question)
-
Displays question in a dialog box and waits for a yes-or-no response. Returns true if the user clicks the OK button, or false if the user clicks the Cancel button. JS 1.0.
- focus()
-
Requests keyboard focus; this also brings the window to the front on most platforms. Returns nothing. JS 1.1.
- getComputedStyle( elt)
-
Returns a read-only Style object that contains all CSS styles (not just inline styles) that apply to the specified document element elt. Positioning attributes such as left, top, and width queried from this computed style object are always returned as pixel values. DOM Level 2.
- moveBy( dx, dy)
-
Moves the window the specified distances from its current position and returns nothing. JS 1.2.
- moveTo( x, y)
-
Moves the window to the specified position and returns nothing. JS 1.2
- open( url, name, features)
-
Displays the specified url in the named window. If the name argument is omitted or if there is no window by that name, a new window is created. The optional features argument is a string that specifies the size and decorations of the new window as a comma-separated list of features. Feature names commonly supported on all platforms are: width=pixels, height=pixels, location, menubar, resizable, status, and toolbar. In IE, set the position of the window with left=x and top=y. In Netscape, use screenX=x and screenY=y. Returns the existing or new Window object. JS 1.0.
- print()
-
Simulates a click on the browser's Print button and returns nothing. Netscape 4; IE 5.
- prompt( message, default)
-
Displays message in a dialog box and waits for the user to enter a text response. Displays the optional default as the default response. Returns the string entered by the user, or the empty string if the user did not enter a string, or null if the user clicked Cancel. JS 1.0.
- resizeBy( dw, dh)
-
Resizes the window by the specified amount and returns nothing. JS 1.2.
- resizeTo( width, height)
-
Resizes the window to the specified size and returns nothing. JS 1.2.
- scroll( x, y)
-
Scrolls the window to the specified coordinates and returns nothing. JS 1.1; deprecated in JS 1.2 in favor of scrollTo().
- scrollBy( dx, dy)
-
Scrolls the window by a specified amount and returns nothing. JS 1.2.
- scrollTo( x, y)
-
Scrolls the window to a specified position and returns nothing. JS 1.2.
- setInterval( code, interval, args...)
-
Evaluates the string of JavaScript code every interval milliseconds. In Netscape 4 and IE 5, code may be a reference to a function instead of a string. In that case, the function is invoked every interval milliseconds. In Netscape, any arguments after interval are passed to the function when it is invoked, but this feature is not supported by IE. Returns an interval ID value that can be passed to clearInterval() to cancel the periodic executions. JS 1.2.
- setTimeout( code, delay)
-
Evaluates the JavaScript code in the string code after delay milliseconds have elapsed. In Netscape 4 and IE5, code may be a function rather than a string; see the discussion under setInterval(). Returns a timeout ID value that can be passed to clearTimeout() to cancel the pending execution of code. Note that this method returns immediately; it does not wait for delay milliseconds before returning. JS 1.0.
Event Handlers
Event handlers for a Window object are defined by attributes of the <body> tag of the document.
- onblur
-
Invoked when the window loses focus.
- onerror
-
Invoked when a JavaScript error occurs. This is a special event handler that is invoked with three arguments that specify the error message, the URL of the document that contained the error, and the line number of the error, if available.
- onfocus
-
Invoked when the window gains focus.
- onload
-
Invoked when the document (or frameset) is fully loaded.
- onresize
-
Invoked when the window is resized.
- onunload
-
Invoked when the browser leaves the current document.
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Comments