self.focus() not working in Opera?

W

WH

I put this line in HTML
<body bgcolor="#FFFFFF" onLoad="focus()">

Both Mozzila and IE can do self.focus(). However Opera still does not take
the focus().
 
T

Thomas 'PointedEars' Lahn

^^^^^^^^^^^^^^
You really want to refrain from spoiling namespaces
and from using a faked From/Reply-To address, see

<http://na.edit.client.yahoo.com/rogers/show_static?.form=eua>
I put this line in HTML
<body bgcolor="#FFFFFF" onLoad="focus()">

Do not use the "bgcolor" attribute without the "text", "link", "alink" and
"vlink" attributes, and, even better, use CSS instead of deprecated format
attributes.
Both Mozzila
What?

and IE can do self.focus().

But you cannot be sure that you call self.focus() here.
However Opera still does not take the focus().

Does the JavaScript Console show error messages?

Without an object reference in an intrinsic event handler attribute value,
the scope chain is followed, so it could be that Opera interprets `focus'
as `document.focus', not `window.focus' == `self.focus'. That's also why
it is bad to write only `open(...)' within an event handler attribute value
as both the object referenced by `window' and the object referenced by
`document' have an open() method according to DOM Level 0 (for `window')
and DOM Level 0+ (for `document').

It could as well be that the DOM of the Opera version(s) you have been
testing with does not support Window.focus(). This method is part of
the proprietary DOM Level 0, it can be supported by a standards compliant
UA but does not need not to.

But why would someone want to focus the window containing the currently
loaded document, even if that worked?


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top