Web Hosting Directory | Web Hosting Resources | Webmaster Resources | Domain Tools | Search Engine Marketing | Forums
  Signup
Today: 1,134   Yesterday: 1,240   Max: 1,872   Total: 364,534   Current Users : 13 (Member 0) 
DOMAIN TOOLS

WEBMASTER TOOLS

RELATED ARTICLES

SUBMIT AN ARTICLE

Write for us and get publicity, link to your website, and best of all get paid. Please visit our writers page for details.


LINK TO US

Link to us and earn points for each visitor you bring to us. Please visit our link partner page for details.

 

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

 
 
What is your major source of website traffic?
 
 
 
 
 
 

ADVERTISEMENT

 
Cheap Web HostingBudget Web HostingEcommerce Web Hosting
Link to UsLink ExchangeAdvertisePrivacy PolicyTerms Of ServiceAbout UsContact UsSitemap
Copyright © 2006 - 2008 Broadband Media, Inc. All rights reserved.