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?

S J
  • 3,210
  • 1
  • 22
  • 32
Michael Banucu
  • 219
  • 2
  • 9

2 Answers2

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

Michael Banucu
  • 219
  • 2
  • 9
0

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

window.scroll(x, y);
dsgriffin
  • 66,495
  • 17
  • 137
  • 137
  • @user2142034 It doesn't? Hmm.. you want scrollBottom right? Check this workaround out - http://stackoverflow.com/questions/4655273/jquery-window-scrolltop-but-no-window-scrollbottom – dsgriffin Mar 06 '13 at 23:34