Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Attributes for <BODY ...>
onFocus = "script command(s)"
onBlur = "script command(s)"

onFocus is the event handler for when the body of the page receives the focus. onBlur is the event handler for when the body loses the focus. For example, the following code puts "focused" in the status bar when the page receives the focus, and "not focused" when it loses the focus.

this code produces this
    onBlur="window.status='not focused'">
this page

There is some difference in how browsers trigger the onFocus event. If the page is not framed, MSIE triggers onFocus when the page is loaded. Netscape, on the other hand, only triggers onFocus if the user actually clicks on the page.

If the page is framed, MSIE and Netscape are relatively consistent with each other. They both trigger onFocus for each framed page when the user clicks on the page. For example, suppose you want the frame that has the focus to change to rad while the other are white. To do this, you could put the following script into the <HEAD> of each page:

<SCRIPT TYPE="text/javascript">
function setbg(color)

Then you could call this script with onFocus and onBlur event handlers like this:

<BODY onFocus="setbg('red')" onBlur="setbg('white')">

That gives us the events on this page.

The body loses the focus when objects inside the body get the focus. So, for example, onBlur is triggered when the user clicks into a form element, such as in this page.

  Copyright 1997-2002 Idocs inc. Published under the terms of the Open Content License Design by Interspire