focus
He every-1,
I try the following:
Code Sample:
...
<body onload="document.ok.focus()">
...
<input type="button" name="ok" value=" OK ">
...
As you'll propably understand, I try to get the focus on the OK-button when the page loads. It won't work.
When I make the button a textfield it DOES work.
Does the focus only work on textfields or am I doing sth wrong?
Shakespeare: onclick || !(onclick)
RC posted this at 13:02 — 21st December 1999.
They have: 89 posts
Joined: Sep 1999
Hello, try this.
<FORM NAME="myFormName">
<INPUT TYPE="text" NAME="myTextField">
<input type="button" name="ok" value="ok"
</FORM>
<SCRIPT LANGUAGE="JavaScript"><!--
document.myFormName.ok.focus();
//--></SCRIPT>
Jack Michaelson posted this at 14:40 — 21st December 1999.
He has: 1,733 posts
Joined: Dec 1999
RC-Thanx 4 reply.
But it won't work either (IE4)
RC posted this at 14:58 — 21st December 1999.
They have: 89 posts
Joined: Sep 1999
Yuck.
It works with NS 4.7 and IE 5..I always forget about those pesky older browsers.
PJ posted this at 16:46 — 21st December 1999.
They have: 76 posts
Joined: Apr 1999
Jack,
I think the only way to give the button focus in older browsers is to click it.
So maybe:
<body OnLoad="document.form.button.click();return false">
The problem with this is it will run any script/page programmed to run when the button is clicked so I guess it's kinda useless, oh well...
Later,
PJ
Anonymous posted this at 00:31 — 22nd December 1999.
They have: 5,633 posts
Joined: Jan 1970
That worked for me in IE4. Check you have the Form Elements names written correctly.
------------------
http://go.to/hass
Jack Michaelson posted this at 07:27 — 22nd December 1999.
He has: 1,733 posts
Joined: Dec 1999
Thanx every-one 4 reply,
lloydhass-the elements were named correctly.
I did get it to work by finding out that when I do this...
..it won't work.
But when I do this...
... it DOES work !
That strange order thingy !
[This message has been edited by Jack Michaelson (edited 22 December 1999).]
[This message has been edited by Jack Michaelson (edited 22 December 1999).]
Shakespeare: onclick || !(onclick)
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.