Stopping web page refreshes in the middle of form-filing

We have a spiffy new intranet at work, otherwise known as hosting a minimal webserver on my PC with a PHP-based message board for internal notices.

Because I just know that half the staff aren't going to refresh their browsers to see if there are any new messages, I wanted the page to refresh automatically every so often.

The obvious way to do this is with <meta http-equiv="refresh" content="1800;URL=mboard.php"> in the head of the page – every 30 minutes this will reload itself.

But what if they're editing a new post at the time? Being cheap and cheerful, this script has the new post form at the bottom of the page that's being refreshed.

With Firefox, this doesn't matter as it will happily refill all the fields. But – as ever – Internet Explorer isn't that nice and blanks the lot.

Two of us have Firefox, everyone else is… well, they don't. And they would complain if this ever happened to them.

So, with a little bit of browsing, it's now has

<!-- blah blah blah, title and stuff -->
<script language="JavaScript" type="text/javascript">
<!-- reload page every fifteen minutes (reset if start entering a new post)
refreshit = setInterval("window.location.reload( true );", 15*60*1000);

and, in the first box of the 'start new thread' form…

<b>Name:</b><br><input type=text name="name" size=30 maxlength=30 onFocus="clearInterval(refreshit);">

i.e. if the box is selected, stop the setInterval function.

Is there an even easier way? Have I missed something horrible? It looks to work – it assumes you've got a JavaScript 1.2 or better browser, but…

Leave a Reply

Your email address will not be published. Required fields are marked *