SetFocus issue...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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

Here is what I'm doing at the moment but it's still not passing focus...

        <script type="button/javascript">
        function setFocus()
    <TITLE>Successful logout</TITLE>
    <BODY class="PageBody" onload=setFocus() >
        <TABLE class="WidgetPanel">
                <TD class="WidgetCell" align="center">
                    <SPAN class="DataLabel">
                        You have been logged out successfully.
                <TD align="center">
                    <INPUT class="button" type="button" onclick="location.replace(
'./index.jsp' )" value="Login" />                                    

Cheers if anyone has any idea's


Re: SetFocus issue...

NiallM wrote:
Quoted text here. Click to load 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.

Quoted text here. Click to load it

type="button/javascript ? Where does that come from?

Quoted text here. Click to load it

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() .

Quoted text here. Click to load it

The title element should be a child of the head element.

Quoted text here. Click to load it

setFocus() should be quoted as ( and ) are not on the list of
characters that can be used in unquoted attribute values.

Quoted text here. Click to load it

Hello? It's 2005, use CSS margins.

Quoted text here. Click to load it

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

As your button doesn't have id="button" it isn't affected at all by the
JavaScript function provided.


Site Timeline