adilsyed — 2007-12-31T01:31:21-05:00 — #1
document.body.addEventListener('onfocus', funBodyFocus, false);
For mozilla browser,
but its not working.
Plz help me on this...
paul_wilkins — 2007-12-31T04:34:14-05:00 — #2
The body has only the onload and onunload events.
asprookie — 2007-12-31T04:38:01-05:00 — #3
Can't focus on the whole body. It defeats the purpose, that's why it doesn't exist .
raju_gautam — 2007-12-31T05:36:52-05:00 — #4
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?
asprookie — 2007-12-31T05:58:47-05:00 — #5
When you browse a page from the URL then automatically the Body will get focused.
Rajug got it right
pepejeria — 2007-12-31T11:22:08-05:00 — #6
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.
mrhoo — 2007-12-31T12:04:34-05:00 — #7
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.