How to add onfocus event to body in javascript for Mozilla Browser

function funBodyFocus()
{
//My Code…
}
document.body.addEventListener(‘onfocus’, funBodyFocus, false);

For mozilla browser,
here i m adding onfocus EventListener to body in javascript.
but its not working.
Plz help me on this…

Regards
Adil

The body has only the onload and onunload events.

Can’t focus on the whole body. It defeats the purpose, that’s why it doesn’t exist .

BTW, what is the purpose of adding new onFocus event on body? When you browse a page from the URL then automatically the Body will get focused. may we know that for what purpose you want to add onFocus event?

When you browse a page from the URL then automatically the Body will get focused.

Rajug got it right

You might want to do this for several reasons. Gmail does this somehow when you have a chat window open and focus the tab/window again. They then change your status to available.

It’s mostly about keyboard navigation.

When the window has focus the tab order may begin at the address bar or in a sidebar of the browser.
If you open the page with no anchor, calling document.body.focus() onload will start the tab order on the first focusable element on the page itself.

You can call document.body.focus() to remove the focus from another element that has the focus.
This has the effect of passing subsequent key events directly to the body. It also resets tab key navigation, sending the user back to the beginning of the page, which can be a problem. It is often best to focus on some element of the body, rather than the body itself.