1

i'm using this:

<head>
    <meta http-equiv="refresh" content="5; URL=<?php $_SERVER['PHP_SELF'] ?>">
</head>

for reloading the page every 5 seconds.
i'm using this:

<script type="text/javascript">
    window.scrollTo(0, document.body.scrollHeight);
</script>

for scrolling down if necessary.
It works fine with Firefox and Internet Explorer but Chrome scrolls only once when loading the page for the first time. Only when I switch the tab (e.g. Ctrl+t) and go back after 5 seconds (Ctrl+w) Chrome scrolls down to the bottom. This is strange! Do I use window.scroll incorrectly or does Chrome behave incorrectly?
Are there any other possibilities for scrolling to the bottom?

2 Answers 2

1

I found the problem: While the page is loading, Chrome has a problem with scroll commands. Solution:

<body onload="setTimeout(function(){window.scrollTo(0,document.body.scrollHeight)}, 1000);">

This works, if loading of page doesn't last more than 1 second (1000 milliseconds).

1
  • What about slow networks? I don't think this would work on every case.
    – tugce
    Oct 26, 2017 at 22:48
0

Have you tried using window.scroll() as an alternative?

window.scroll(x, y);
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.