Share via


IHTMLWindow2 interface

This interface provides access to the window object, which represents an open window in the browser.

Members

The IHTMLWindow2 interface inherits from the IDispatch interface. IHTMLWindow2 also has these types of members:

  • Methods
  • Properties

Methods

The IHTMLWindow2 interface has these methods.

Method Description
alert

Displays a dialog box containing an application-defined message.

This method is not supported for Windows apps using JavaScript.

blur

Causes the element to lose focus and fires the HTMLFrameSiteEvents::onblur event.

clearInterval

Cancels the interval previously started using the IHTMLWindow2::setInterval method.

clearTimeout

Cancels a time-out that was set with the IHTMLWindow2::setTimeout method.

close

Closes the current browser window or HTA.

Closes the app without prompting the user. To the user, it appears as though the app has crashed.

confirm

Displays a confirmation dialog box that contains an optional message as well as OK and Cancel buttons.

This method is not supported for Windows apps using JavaScript.

execScript
Note   IHTMLWindow2::execScript is no longer supported. Starting with IE11, use eval. For info, see Compatibility changes.
 

Executes the specified script in the provided language.

focus

Causes the element to receive the focus and executes the code specified by the HTMLFrameSiteEvents::onfocus event.

item

Retrieves a frame or iframe object from the collection.

moveBy

Moves the screen position of the window by the specified x and y offset values.

moveTo

Moves the screen position of the upper-left corner of the window to the specified x and y position.

navigate

Loads the specified URL to the current window.

open

Opens a new window and loads the document specified by a given URL.

Navigates the app window to the specified location.

prompt

Displays a dialog box that prompts the user with a message and an input field.

resizeBy

Changes the current size of the window by the specified x- and y-offset.

resizeTo

Sets the size of the window to the specified width and height values.

scroll

Causes the window to scroll to the specified x- and y-offset at the upper-left corner of the window.

scrollBy

Causes the window to scroll relative to the current scrolled position by the specified x- and y-pixel offset.

scrollTo

Scrolls the window to the specified x- and y-offset.

setInterval

Evaluates an expression each time a specified number of milliseconds has elapsed.

setTimeout

Evaluates an expression after a specified number of milliseconds has elapsed.

showHelp

Displays a Help file. This method can be used with Microsoft HTML Help.

showModalDialog

Creates a modal dialog box that displays the specified HTML document.

 

Properties

The IHTMLWindow2 interface has these properties.

Property Description

closed

Retrieves whether the referenced window is closed.

defaultStatus

Sets or retrieves the default message displayed in the status bar at the bottom of the window.

length

Sets or retrieves the number of objects in a collection.

name

Sets or retrieves a value that indicates the window name.

offscreenBuffering

Sets or retrieves whether objects are drawn offscreen before being made visible to the user.

onblur

Sets or retrieves a pointer to the event handler function associated with the HTMLFrameSiteEvents::onblur event.

onfocus

Sets or retrieves a pointer to the event handler function associated with the HTMLFrameSiteEvents::onfocus event.

onload

Sets or retrieves a pointer to the event handler function associated with the HTMLFrameSiteEvents::onload event. The HTMLFrameSiteEvents::onload event occurs immediately after the browser loads the object.

onresize

Sets or retrieves a pointer to the event handler function associated with the HTMLFrameSiteEvents::onresize event.

onscroll

Sets or retrieves a pointer to the event handler function associated with the HTMLFrameSiteEvents::onscroll event.

opener

Sets or retrieves a reference to the window that created the current window.

parent

Retrieves the parent of the window in the object hierarchy.

self

Retrieves a reference to the current window or frame.

status

Sets or retrieves the message in the status bar at the bottom of the window.

top

Retrieves the topmost ancestor window.

 

Remarks

The window object is used to retrieve information about the state of the window. It also is used to gain access to the document in the window, to the events that occur in the window, and to features of the browser that affect the window.

Typically, the browser creates one window object when it opens an HTML document. However, if a document defines one or more frames—that is, contains one or more frame or iframe tags—the browser creates one window object for the original document and one additional window object for each frame.

These additional objects are child windows of the original window and can be affected by actions that occur in the original. For example, closing the original window causes all child windows to close. You can also create new windows and corresponding window objects by using methods such as IHTMLWindow2::open and IHTMLWindow2::showModalDialog.

This interface may also be referred to in code as IOmWindow2.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows 2000 Server

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

IDispatch

Reference

IHTMLWindow3

IHTMLWindow4

IHTMLWindow5