www.fgks.org   »   [go: up one dir, main page]

Click to Rate and Give Feedback
Methods
 hasFocus Method
hasFocus Method

Gets a value indicating whether the object currently has focus.

Syntax

bActive = document.hasFocus()

Return Value

Boolean. Returns one of the following values.

trueDocument has focus.
falseDocument does not have focus.

Example

The following example shows how to use the hasFocus method to determine if the document has focus.

<HTML>
<HEAD>
<SCRIPT>
function fnCallDialog()                                             
{
 showModelessDialog("myDialogHasFocus.htm",window,"status:false;dialogWidth:300px;dialogHeight:300px");
}
// Function displays the message DIV when the main document has focus
function fnOpenMessage()
{
	if (document.hasFocus())
	{
		oMessageDiv.style.display = "block";
	}
}
function fnCloseMessage()
{
	oMessageDiv.style.display = "none";
}
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="button" 
VALUE="Display Modeless Dialog" >
<P>
<SPAN STYLE= "color:darkmagenta;font-size:large;"  
>Mouse over this!</SPAN>

<div id="oMessageDiv" style="display:none;width:200;font-family: 
arial;font-size:large; color: steelblue; border: 4 solid gold;">
A message for you!
</div>

</BODY>
</HTML>	
This feature requires Microsoft® Internet Explorer 5.5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

There is no public standard that applies to this method.

Applies To

document
Tags What's this?: Add a tag
Community Content
 
Add Community Content
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker
DCSIMG