Web Development HTML Guide - Learn HTML
Developer Tutorials
ASP
CGI & Perl
CSS
Flash
HTML
Java
JavaScript
Linux
MySQL
PHP
Photoshop
Python
Wireless
XML



Developer Manuals
Learn HTML
Learn PHP
Learn MySQL
Learn CSS
Learn Pear


Developer Scripts
ASP Scripts
ASP.NET Scripts
CGI & Perl Scripts
Flash Scripts
Java Scripts
JavaScript Scripts
PHP Scripts
Python Scripts
Remotely Hosted Scripts
Tools & Utilities Scripts
XML Scripts

Developer Resources
Developer Tools
Developer News
Developer Forums
Developer Content
Developer Book Reviews
Survey Software

Web Hosting Directory
Budget Web Hosting
ColdFusion Hosting
Dedicated Servers
Domain Hosting
E-Commerce Hosting
Email Hosting
Free Web Hosting
Linux Web Hosting
Managed Hosting
Reseller Hosting
Small Business Hosting
Windows Web Hosting

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
<BODY
    onFocus="window.status='focused'"
    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)
{
document.bgColor=color;
document.body.style.backgroundColor=color;
}
//-->
</SCRIPT>

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 Idocs, Inc. Written by Miko Sullivan











About the NetVisits, Inc Network | Advertise
Developer Tutorials hosted by HostGator.
Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy.
Visit other NetVisits, Inc. sites: