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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnBlur event

Status
Not open for further replies.

rr236

IS-IT--Management
Oct 23, 2000
37
GB
I been told that by using the onblur event in the body tag, one can ensure that a form remains topmost.

However, in trying to use this logic I have found that the forms input fields can not be edited.

Here is my code for using the onblur event

<body onblur=&quot;javascript:window.focus();&quot;>

Is this correct, and if it is how can I edit my form?

Your help will be greatly appreciated. (My users all use IE5 aND IE5.5).

thanks
rr236
 
The onblur event is when the object in question does not have the users focus. When you put it on the body tag, it efects the window. what you want it the the text field.

<input onblur=&quot;this.focus();&quot;>

Just to let you know, this will mean that they can do nothing other then use this field, because it will always have focus. You may want to do something like this:

<body onload=&quot;document.formName.fieldName.focus()&quot;>

This way the field will start with the focus, but the user has the choice to blur it.
 
To elaborate on Theocraticmind - the onblur event &quot;happens&quot; when an object &quot;goes out of focus&quot;. A form element (text box, radio button, checkbox, etc.) is by default &quot;out of focus&quot; and unless you specifically place the focus on an object, as Theocraticmind has shown, then all form elements are &quot;blurred&quot; and will never respond because no element was ever &quot;in focus&quot;. It's a little confusing at first but if you play with the focus and onblur event handlers a little bit you'll soon &quot;see the light&quot;.

There's always a better way...
 
thanks for your comments, I think I understand why I can't enter data into my input fields if I'm using a general OnBlur event.

However, taking Theocraticmind's idea regards putting the focus on an input field, I have 6 fields I need to enter data into. 5 are simple input fields, and the sixth is a textarea.

Is it possible for me to force focus on say field1 when opening the window, but on clicking into another field say field4, make that the field that maintains focus.

Since the idea is to ensure the window stays topmost, maybe theres a way of triggering a bring to top type command, if it another window becomes topmost (obviously we need to make sure the 2 windows are competing for being at the top otherwise a vicious circle ensues)?

thanks
RR236
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top