Using the hasFocus Method to Determine Window Focus

Move the cursor over the "Mouse over this!" text and take note of the effect. Next, click on the button. A modeless window displays and take focus away from the main window. Now move the cursor over the text again. Notice that there is no effect while the modeless window has focus. This is because this example uses the hasFocus method to check if the main window has focus and if it does not, to prevent script associated with the onmouseover event from proceeding.

Mouse over this!

©© 2007 Microsoft Corporation. All rights reserved. Terms of use.