www.fgks.org   »   [go: up one dir, main page]

Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
Events
 onblur Event
onblur Event

Fires when the object loses the input focus.

Syntax

Inline HTML<ELEMENT onblur = "handler" ... > All platforms
Event propertyobject.onblur = handlerJScript only
object.onblur = GetRef("handler")Visual Basic Scripting Edition (VBScript) 5.0 or later only
Named script <SCRIPT FOR = object EVENT = onblur> Internet Explorer only

Event Information

BubblesNo
CancelsNo
To invoke
  • Click the mouse on the document background or another control.
  • Use the keyboard to navigate from one object to the next.
  • Invoke the blur method when an object has focus.
  • Switch focus to a different application or open a second browser window.
Default action Switches focus away from the object on which the event is fired.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query the event object for the following event properties.

Available Properties

altKey Sets or retrieves a value that indicates the state of the ALT key.
altLeft Sets or retrieves a value that indicates the state of the left ALT key.
clientX Sets or retrieves the x-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
clientY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
ctrlLeft Sets or retrieves the state of the left CTRL key.
offsetX Sets or retrieves the x-coordinate of the mouse pointer's position relative to the object firing the event.
offsetY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the object firing the event.
screenX Sets or retrieves the x-coordinate of the mouse pointer's position relative to the user's screen.
screenY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the user's screen.
shiftLeft Retrieves the state of the left SHIFT key.
srcElement Sets or retrieves the object that fired the event.
type Sets or retrieves the event name from the event object.
x Sets or retrieves the x-coordinate, in pixels, of the mouse pointer's position relative to a relatively positioned parent element.
y Sets or retrieves the y-coordinate, in pixels, of the mouse pointer's position relative to a relatively positioned parent element.

Remarks

The onblur event fires on the original object before the onfocus or onclick event fires on the object that is receiving focus. Where applicable, the onblur event fires after the onchange event.

Use the focus events to determine when to prepare an object to receive or validate input from the user.

As of Microsoft Internet Explorer 5, you must set the tabIndex attribute of elements that expose the onblur event.

For Internet Explorer 5 and later, the onblur event is asynchronous.

Example

This example shows how to display the name of the object that has lost focus, that is, the object that fires the onblur event.

<html>

<body>

<input type="text" 
    name="txtFName" 
    value="First Name" 
    >
<input type="text" 
    name="txtLName" 
    value="Last Name" 
    >
<input type="text" 
    name="txtPhone" 
    value="Phone" 
    >

</body>

</html>
This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

This event is defined in HTML 4.0 World Wide Web link.

Applies To

A, ABBR, ACRONYM, ADDRESS, APPLET, AREA, B, BDO, BIG, BLOCKQUOTE, BUTTON, CAPTION, CENTER, CITE, CUSTOM, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, hn, HR, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OBJECT, OL, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, window, XMP

See Also

blur, focus, onfocusout
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content      
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker
DCSIMG