This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

setActive

Method of dom/HTMLElementdom/HTMLElement

Syntax

var object = object.setActive();

Return Value

Returns an object of type DOM NodeDOM Node

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

This example demonstrates how to use the setActive method between frames.

...
<SCRIPT>
function fnBottomActive(){
    //Set the object with ID=btnLarger active in frame with ID=oFrame1.
    window.parent.oFrame1.secondButton.setActive();
}
</SCRIPT>
...

View live example

This example demonstrates how to use the setActive method between windows. By clicking the SetActive button in the left window, the method sets the Second Button as the active object in the right window, although the object does not receive focus. The object receives focus when its page receives focus. To confirm that the object is active, click the right window’s title bar. The button appears to be selected.

<HTML>
<HEAD>
<SCRIPT>
function fnOpen(){
    //Open new window.
    oWin1 = window.open("/workshop/samples/author/dhtml/refs/setactive_content.htm",
        "oWin1",
        "top=10px,left=480px,height=375px,width=200px,resizable=1");
    //Set focus back to the parent window.
    this.focus();
}
function fnBottomActive(){
    //Set the object with ID=btnLarger active in the other window.
    window.parent.oWin1.secondButton.setActive();
}
</SCRIPT>
</HEAD>
<BODY onload="fnOpen();">
<CENTER>
<TABLE border="1">
<TR><TD>
    <BUTTON id="btn1" onclick="fnBottomActive();">Set Active</BUTTON></TD></TR>
</TABLE>
</CENTER>
</BODY>
</HTML>

View live example

Notes

Remarks

The setActive method does not cause the document to scroll to the active object in the current page or in another frame or window.

Syntax

Standards information

There are no standards that apply here.

Attributions