
This interface provides access to the window object which represents an open window in the browser. You use the window object to retrieve information about the state of the window and 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 open and showModalDialog.
IHTMLWindow2 Methods
HRESULT alert(
BSTR message
);
Displays an Alert dialog box with a message and an OK button.
The title bar of the Alert dialog box cannot be changed.
HRESULT blur(
void
);
Causes the window to lose focus and fires the onblur event.
See also focus
HRESULT clearInterval(
long timerID
);
Cancels a repeated evaluation of an expression that was set with the setInterval method.
See also setInterval
HRESULT clearTimeout(
long timerID
);
Cancels a time-out that was set with the setTimeout method.
See also setTimeout
HRESULT close(
void
);
Closes the current browser window.
HRESULT confirm(
BSTR message,
VARIANT_BOOL *confirmed
);
Displays a Confirm dialog box with the specified message, and OK and Cancel buttons.
The title bar of the confirm dialog box cannot be changed.
HRESULT execScript(
BSTR code,
BSTR language,
VARIANT *pvarRet
);
Executes the specified script.
HRESULT focus(
void
);
Causes the window to receive the input focus and execute the code, if any, associated with the onfocus event.
See also blur
HRESULT get__newEnum(
IUnknown **p
);
Returns an OLE enumeration interface. This will enumerate over the frames collection of this window.
HRESULT get_clientInformation(
IOmNavigator **p
);
Retrieves an interface pointer to a navigator object that represents the browser. The object provides information about the browser.
See also IOmNavigator
HRESULT get_closed(
VARIANT_BOOL *p
);
Retrieves a value indicating whether the window is closed.
HRESULT get_defaultStatus(
BSTR *p
);
Retrieves the default message displayed in the status bar at the bottom of the window.
Do not confuse the defaultStatus property with the status property retrieved by the get_status method. The status property reflects a priority or transient message in the status bar, such as the message that appears when an onmouseover event occurs over an anchor.
See also put_defaultStatus
HRESULT get_document(
IHTMLDocument2 **p
);
Retrieves an interface pointer to the document object for the document that the browser is displaying.
See also IHTMLDocument2
HRESULT get_event(
IHTMLEventObj **p
);
Retrieves an interface pointer to the event object that contains information relevant to the most recent event.
See also IHTMLEventObj
HRESULT get_external(
IDispatch **p
);
Retrieves external access to an additional object model provided by host applications of the Internet Explorer browser components.
In the Internet Explorer stand-alone browser, no external object model is available. In a hosting scenario where it is available, the object model is defined by the application hosting the Internet Explorer components, and the hosting application should be referred to for documentation. For further details on how to implement extensions to the object model, see the Internet Client SDK documentation on "Reusing the WebBrowser and MSHTML".
HRESULT get_frames(
IHTMLFramesCollection2 **p
);
Retrieves an interface pointer to a zero-based collection of all the FRAME elements in an HTML document, if the document contains the FRAMESET element. If the document contains the BODY element, this is a collection of all IFRAME elements in the document. In either case, the elements are in the same order as they appear in the document.
The collection is indexed first by name, then by ID. If duplicate names are found, a collection of those named items is returned. The resulting collection can be only referenced by ordinal position.
HRESULT get_history(
IOmHistory **p
);
Retrieves an interface pointer to a history object that contains information about all the URLs that the client has visited.
HRESULT get_Image(
IHTMLImageElementFactory **p
);
Returns an IHTMLImageElementFactory pointer that is used to create an offscreen image.
HRESULT get_location(
IHTMLLocation **p
);
Retrieves an interface pointer to a location object. The object contains information about the current location (full URL) of the document.
HRESULT get_name(
BSTR *p
);
Retrieves the name of the window.
The name property on the window comes from the FRAME definition. There is no other way to persist a window name in HTML.
See also put_name
HRESULT get_navigator(
IOmNavigator **p
);
Retrieves an interface pointer to a navigator object that represents the browser. The object provides information about the browser.
See also IOmNavigator
HRESULT get_offscreenBuffering(
VARIANT *p
);
Determines whether an offscreen buffer is being used.
See also put_offscreenBuffering
HRESULT get_onbeforeunload(
VARIANT *p
);
Retrieves the inline script associated with the onbeforeunload event before a window element is unloaded. This event is fired before the onunload event. It provides an opportunity to warn the user if the window is currently in an unsaved state and the information will be lost.
For more information on inline script, see Attaching an Event Handler in the Event Model documentation.
The handler for this event should return NULL if doing the unload is safe, or a text string to prompt the user to decide to cancel or continue with the unload operation. Only the user's response to the warning can stop the new navigation causing the unload; the event handler itself cannot unilaterally block the operation. If the handler returns a non-NULL string, a modal dialog box appears that displays the explanatory string. The dialog box shows three buttons with the message for user action:
In the case of frames, the full sequence of onbeforeunload events are fired on each frame in the same order, depth-first, that onunload events are about to be fired. A dialog box is presented for each event handler that returns a non-NULL string. The first Cancel response stops the potential navigation, in which case no unload occurs. If there is no Cancel response, the unload proceeds and onunload events fire.
See also put_onbeforeunload
HRESULT get_onblur(
VARIANT *p
);
Retrieves the inline script associated with the onblur event when the window element loses the focus.
For more information on inline script, see Attaching an Event Handler in the Event Model documentation.
See also put_onblur
HRESULT get_onerror(
VARIANT *p
);
Retrieves the inline script associated with the onerror event on the window element.
For more information on inline scripts, see Attaching an Event Handler in the Event Model documentation.
See also put_onerror
HRESULT get_onfocus(
VARIANT *p
);
Retrieves the inline script associated with the onfocus event on the window element.
For more information on inline scripts, see Attaching an Event Handler in the Event Model documentation.
See also put_onfocus
HRESULT get_onhelp(
VARIANT *p
);
Retrieves the inline script associated with the onhelp event on the window element.
For more information on inline scripts, see Attaching an Event Handler in the Event Model documentation.
This script is executed when the user presses the F1 key or clicks the Help button in the browser. The default action of this event is to display the help information for the browser.
See also put_onhelp
HRESULT get_onload(
VARIANT *p
);
Retrieves the inline script that is executed immediately after the browser loads the given object.
See also put_onload
HRESULT get_onresize(
VARIANT *p
);
Retrieves the inline script that is executed when the object is resized.
See also put_onresize
HRESULT get_onscroll(
VARIANT *p
);
Retrieves the inline script that is executed when the scroll box is repositioned. The default action of this event is to scroll.
See also put_onscroll
HRESULT get_onunload(
VARIANT *p
);
Retrieves the inline script that is executed immediately before the page is unloaded.
See also put_onunload
HRESULT get_opener(
VARIANT *p
);
Retrieves a reference to the window that created the current window.
See also put_opener
HRESULT get_Option(
IHTMLOptionElementFactory **p
);
Retrieves an interface pointer to a factory object that you can use to create OPTION elements. You can add the elements to a SELECT block by using the IHTMLSelectElement::add method.
See also IHTMLOptionElementFactory, IHTMLSelectElement::add
HRESULT get_parent(
IHTMLWindow2 **p
);
Retrieves an interface pointer to the parent object in the object hierarchy.
In a FRAMESET and FRAME relationship, this function retrieves an object representing the FRAMESET window. On a document, the parent is the window.
HRESULT get_screen(
IHTMLScreen **p
);
Retrieves an interface pointer to a screen object that provides information about the client's screen and rendering abilities
See also IHTMLScreen
HRESULT get_self(
IHTMLWindow2 **p
);
Retrieves an interface pointer to the current window.
Use the self property to disambiguate a window property from a form of the same name.
HRESULT get_status(
BSTR *p
);
Retrieves the message displayed in the status bar at the bottom of the window.
Do not confuse the status property with the defaultStatus property retrieved by the get_defaultStatus method. The status property reflects a priority or transient message in the status bar, such as the message that appears when an onmouseover event occurs over an anchor.
See also put_status
HRESULT get_top(
IHTMLWindow2 **p
);
Retrieves an interface pointer to the topmost ancestor window, which is the current window's own parent.
HRESULT get_window(
IHTMLWindow2 **p
);
Retrieves an interface pointer to the current window.
Use the self property to disambiguate a window property from a form of the same name.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.