Forum Moderators: open

Message Too Old, No Replies

maintain focus on borderless input=text form element

         

Uscs

7:10 pm on Oct 24, 2003 (gmt 0)

10+ Year Member



I've got a PERL page that outputs some data along with a borderless FORM INPUT="text" element so that when the document is printed out, some notes can by typed by the user within the INPUT field.

It's a neat effect, kind of makes you think you are typing directly on a webpage.

Anyway, what I want to do is maintain focus on the INPUT text element so that the blinking cursor tells the user that there's somewhere to type.
Currently, I've got:
<BODY onLoad='document.forms[0].elements[0].focus();'>
But, after the page loads, if the user clicks anywhere EXCEPT the INPUT text element, the cursor goes away.
I've played with the onBlur() function:
<INPUT TYPE='text' SIZE=40 MAXLENGTH=40 onblur='this.focus();'>
but it's quite unforgiving. What I mean by that is if the webpage is minimized, or if the user wants to print it, even though the window goes away, it's still got focus.

Maybe I need to choose specific elements of the webpage that, if clicked, will transfer focus to the INPUT text field.
For example:
-anywhere in the background of the window
-a picture
-other text

Any ideas?

BlobFisk

4:43 pm on Oct 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried either of these DOM conventions:

document.formName.fieldName.focus();
for <input name="fieldName">

or

document.getElementById('fieldID').focus();
for <input id="fieldID">

HTH