Fire-House 58

Event Handlers

onBlur

e-1


JavaScript:
firehouse58.com onBlur event handlers execute script when the mouse cursor loses focus from an object.

 

Hard Reload
To See Menu

Type something in this text
object.Then lose focus.

 

<script language="JavaScript">
<!--

onBlur

function testy_(){
var string_ = document.test.one.value
document.test.two.value= string_ }

// -->
</script>

The function testy_ converts the value of the text object document.test.one.value to the variable string_. It then sets the value of  document.test.two.value to string_.     

<form name="test">
<input language="JavaScript" type="text" onBlur="testy_()" size="20" name="one">

<input type="text" size="20" name="two">
</form>

The onBlur event handler in the text object one calls the function testy_ when the cursor leaves or blurs the text object.  

H
I
N
T

Of Course, this event handler can be used with various objects: text, textarea, window. I use this event handler with the window focus method to keep pop-up windows on top. <body onBlur="self.focus()"> 






method

blur()
 

Time:
Date:

N
O
T
E

Switch gears a liitle, I have alot of space to fill, so many of the event handler pages will contain similar methods. This should help clarify the difference. Event handlers detect events, methods are more like commands.

<form name="clock">
Time:
<input type="text" name="time" size="8"
onFocus="this.blur()"><br>
Date:
<input type="text" name="date" size="8" value>

The time field uses the method blur() to keep users from accessing the field. The date field does not use the method. Users can access the field, but the value constantly updated by an external script.

 


[back]   [home]   [next]