Why does Opera lose the focus on a input box if I scroll with a JavaScript

S

Stefan Mueller

With
document.MyForm.MyField.focus();
I set the focus to the input field just after the page has been loaded. This
works perfect.
Two seconds later the JavaScript
window.setTimeout("window.scrollTo(0, 0)", 2000);
scrolls to the top of the page.
Unfortunately in Opera the input box loses the focus after the scrolling
event. With Internet Explorer and Mozilla the focus is still on the input
box.

Is there a way (workaround) to keep the focus also with Opera on the input
box?

Stefan

====================================

<html>
<script type = 'text/javascript'>
function AfterLoad() {
document.MyForm.MyField.focus();
window.setTimeout("window.scrollTo(0, 0)", 2000);
}
</script>

<body onLoad = "AfterLoad()">
<form name="MyForm">
Top Row
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<input type = "input" name = "MyField" value = "">
</form>
</body>
</html>
 
L

Leif K-Brooks

Stefan said:
I set the focus to the input field just after the page has been loaded. This
works perfect.
Two seconds later the JavaScript
window.setTimeout("window.scrollTo(0, 0)", 2000);
scrolls to the top of the page.

What reason could you possible have to do that other than to annoy your
visitors?
 
S

Stefan Mueller

Did you really not see the next sentence and the consequent question of my
post?
The posted code was just a simple example to show my problem.

Stefan
 
S

Spartanicus

Stefan Mueller said:
Did you really not see the next sentence and the consequent question of my
post?

Who and what are you addressing? Quote a minimal bit of what you are
replying to.
The posted code was just a simple example to show my problem.

[browsing up the thread]

Instead of multi posting a nonsensical question, you should have
indicated in your first post that you didn't want to reveal what you are
actually trying to do, that way we would not have wasted any time by
replying to you.
 
S

Stefan Mueller

Who and what are you addressing? Quote a minimal bit of what you are
replying to.

Sorry, but my provider doesn't allow me to quote more text than I write.
It's a new setting on the news server. I've already complained about but
they told me that this setting is quite common because so if you search a
conversation on the internet you don't have to read the same text again and
again.
However, I just answered the post before.

I'm just trying to find a solution so that Opera does not lose the focus on
a input box if you scroll the page with a Javascript. With Internet Explorer
and Mozilla the focus is still on the input box.

Stefan
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top