Posted by Steve Pugh on 11/16/01 11:32
NiallM wrote:
> Any chance anyone could spare a sec to see where i'm going wrong here?
>
> On loading a page i'm trying to sefocus to a button on the page, (the only
> button) so that I can press return and it will have the effect of clicking
> it.
As you talk about yourself being the one who will press return I
presume this is a personal page that no one else will use. If it is
going on the WWW for general use then don't muck about with the focus
at all.
> Here is what I'm doing at the moment but it's still not passing focus...
>
> <HTML>
> <HEAD>
>
> <script type="button/javascript">
type="button/javascript ? Where does that come from?
> function setFocus()
> {
> document.button.focus();
That assumes the MSIE document model and gives focus to the element
with id="button". The standard way of doing this would be
document.getElementById('button').focus() .
> }
> </script>
>
> </HEAD>
> <TITLE>Successful logout</TITLE>
The title element should be a child of the head element.
> <BODY class="PageBody" onload=setFocus() >
setFocus() should be quoted as ( and ) are not on the list of
characters that can be used in unquoted attribute values.
> <BR><BR><BR><BR><BR><BR><BR>
Hello? It's 2005, use CSS margins.
> <INPUT class="button" type="button" onclick="location.replace(
> './index.jsp' )" value="Login" />
If all the button is doing is calling a new page then an ordinary link
is more reliable. You can even style it to look like a button if you
want.
As your button doesn't have id="button" it isn't affected at all by the
JavaScript function provided.
Steve
Navigation:
[Reply to this message]
|