PDA

View Full Version : Refreshing a page when i want it to


Badman3k
04-16-2004, 08:33 PM
I have a webpage that has a single div layer. This layer shows a load of messages that are constantly changing via PHP.
I want the page to refresh every 2 seconds, but i want it to stop refreshing if the user trys to scroll down the div layer.
If i use the meta tag trick it doesn't matter what's going on it'll refresh regardless, but if my messages are appearing quickly i need it to be possible for the user to scroll through the messages, so he/she can view them.

I hope that this makes sense, it's a little tricky to explain.

Many thanks in advance,

sad69
04-16-2004, 08:42 PM
If they stop scrolling, do you want it to start refreshing again?

I don't know if there's an event like onScroll or something, but instead of meta refreshes, you should use setTimeout to call a method that checks a boolean before it tries to refresh (true means allowed to refresh, false means not allowed to refresh) every 2 seconds. If you've got that onScroll event, then you can set that boolean to false, so it won't refresh, and set another timeout 2 set the boolean back to true in a 2 seconds. Then in another 2 seconds it'll call that method again and see if it's allowed to refresh....

But this is totally dependent on that onScroll event... if you can't detect it, you're sorta out of luck.

Good luck,
Sadiq.

Roy Sinclair
04-16-2004, 08:43 PM
No time right now to write you a sample but you can use a simple javascript to trigger the page reload and the onfocus event for the div could be used to cancel the reload while the onblur event could resume it. Alternatively, you could consider using a couple of buttons so the users have a more defined sense of control.