Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the difference between onblur & onfocusout? 1

Status
Not open for further replies.

ajindal

Programmer
Oct 7, 2003
11
IN
Hi, What is the diff. b/e onfocusout and onblur event?
The problem is that if i use onBlur(), it causes the whole application to crash but on replacing the OnBlur with onFocusout the application works fine. The problem comes when i try to close my window. I tried debugging and found out that the window was closed and then the onBlur event was trying to get fired which was crashing the application!!!

Can anyone help me provide me with a reason for this.

Regards,
Akhil
 

>> What is the diff. b/e onfocusout and onblur event

AFAIK, onblur occurs before the element loses focus, and onfocusout occurs after it has lost focus, and another element has gained focus.

I can't say why your app is crashing - how about posting some code, or a URL to some code?

Hope this helps,
Dan
 
Hi Billy,
This is some additional information I have found out. You are right, but the question arises that why does not onblur get fired when I close the window and why does it try to get fired after the window is closed. According to u the onBlur should be fired before the onfocusout which is not the case. My code is also working fine if I use ondeactivate event.
Regards
Read below-->
The onActivate and onDeactivate event handlers are new with IE5.5. But in
some circumstances, they are very similar to the onFocus and onBlur event han-dlers,
respectively. If an element receives focus, the onActivate event fires for that
element just before the onFocus event fires; conversely, just prior to the element
losing focus, events fire in the sequence: onBeforeDeactivate , onDeactivate ,
onBlur . Only elements that, by their nature, can accept focus (for example, links
and form input controls) or that have a TABINDEX attribute set can become the
active element (and therefore fire these events).


IE5.5 adds the onDeactivate event handler, which fires immediately before the
onBlur event handler. Both the onBlur and onDeactivate events can be blocked
if the onBeforeDeactivate event handler function sets event.returnValue to
false .
 
Ahkil, you're asking for help on a problem that we can't see. It's best to post a link to the page or the code. Otherwise, it's just a guessing game.

There's always a better way. The fun is trying to find it!
 
Unlike onblur event, onfocusout bubbles.
onblur also fires when user switches to another window/app or invokes blur() method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top