Why is the scrolling function not working with Internet Explorer

S

Stefan Mueller

I'd like to set the focus to a field which is quite at the bottom of my
page. But I'd like that the page is shown at the top. If you press a key the
page should scroll down to the field.
In Mozilla and Opera the following code works fine. But why isn't it working
with the Internet Explorer?

Stefan

PS: If I don't set the focus to the filed I can scroll with
window.scrollTo(0, 20);
to every place where I'd like to also with the Internet Explorer.

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

<html>
<script type = 'text/javascript'>
function AfterLoad() {
document.MyForm.MyField.focus();
window.scrollTo(0, 0); // Supposed to be scrolling to the top of
the page
}
</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>
 
B

BootNic

<script type = 'text/javascript'>
function AfterLoad() {
document.MyForm.MyField.focus();
window.scrollTo(0, 0); // Supposed to be scrolling to the
top of the page
}
</script>

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

Stefan Mueller

function AfterLoad() {
document.MyForm.MyField.focus();
setTimeout('window.scrollTo(0, 0)',1);
}
</script>

Great, this works perfect.

Many thanks
Stefan

PS: Do you think it's a bug or only a timing problem?
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top