Availability: |
| ||||||
Property/method value type: | Boolean primitive | ||||||
JavaScript syntax: | - | myObject.onblur = aHandler | |||||
HTML syntax: | <BODY onBlur="aHandler"> <FRAMESET onBlur="aHandler"> <HTMLTag onBlur="aHandler"> <INPUT onBlur="aHandler"> | ||||||
Argument list: | aHandler | A reference to a function object to handle the event | |||||
Supported by objects: | A, Anchor, APPLET, AREA, BUTTON, CAPTION Checkbox, DIV, Embed, FIELDSET, FileUpload, IMG, Input, Layer, LEGEND, MARQUEE, OBJECT, Password, RadioButton, ResetButton, Select, SPAN, SubmitButton, TABLE, TD, TEXTAREA, TextCell, TH, TR, Url |
A blur event is caused by the user clicking on another window or frame, or the blur() method being called for an object. When this event is triggered, an onBlur event handler will be invoked.
The onblur event handler is a function, which is represented by an object that is referred to by this property. Because it is stored in a property, you can change the handler by storing a reference to a different function object in this property. At least, you can on MSIE.
You cannot redefine the value of the window.onblur property from inside the onblur function handler. This means you can't modify the onblur behavior while a blur event is in progress.
Netscape will pass an Event object as an argument when it calls this event handler function. MSIE does not pass an object but makes the event data available via the Event object that is stored and accessed globally for all events.
DOM level 2 refers to this as a DOMFocusOut event, which employs event bubbling for its propagation and cannot be canceled.
It is somewhat easy to create an onBlur/onFocus recursion, which leads to an endless loop with objects exchanging focus backwards and forwards. Focus on object A triggers a blur event on object B, which tries to wrest back the focus again because it believes its content is incomplete. Meanwhile object A isn't happy with its content either and so they play 'Tug-of-War' with one another. This continues until the browser has a race hazard attack and GPFs - that is if it hasn't already fallen over due to a stack overflow. If you're lucky only the browser will crash, but it could bring down the OS as well.
Prev | Home | Next |
onBeforeUpdate | Up | onBounce |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |