It not a joke!!! It is the truth!!!

Giving people what they want: violence and sloppy eating

Previous Entry Share Next Entry
Stopping web page refreshes in the middle of form-filing
mini me + poo
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...

  • 1
Put the message submission form and the message window in seperate frames?

I know frames are supposed to be evil for some people, but this would this be a legitimate use of it?

(Deleted comment)

Re: Is this possible?

The main problem with this is that it involves much more hacking around with the message board script than I'd like to do.

As this works, I'm happy with it.

I must keep reminding people that the main charity paid £20k for something not much better...

  • 1

Log in

No account? Create an account