Uutiset:

Wondering if this will always be free?  See why free is better.

Main Menu
Advertisement:

Forcing a Page to Reload

Aloittaja The Wizard, heinäkuu 22, 2013, 10:29:06 AP

« edellinen - seuraava »

The Wizard

Hello:

I need a page to reload/refresh to update the information seen. I was thinking along the lines of the following -

template.php page


    if(isset($context['reloadPage']))
{
unset($context['reloadPage']);
//no outputting code above header
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
}


and adding this in the

Subs.php page


$context['reloadPage'] = true;


So do you all think it will work, or is there a better way to make this happen.

thanks

Wiz

The Wizard

Well that did not work. Anybody have any ideas?

IchBin™

Javascript is the way to make the page refresh on a timer. setInterval() is the js function if I remember right.
IchBin™        TinyPortal

NIAB

Use jQ :) Its handy.

if(window.top==window) {
    // you're not in a frame so you reload the site
    window.setTimeout('location.reload()', 3000);

The Craw

Oddly enough, I immediately thought of setInterval as well, however it occurs to me that the function given is only going to execute once. Therefore the "interval" part is pretty much void. If it were me, I'd probably add this to Load.php


$context['html_headers'] .= '
<script type="text/javascript">
    window.onload = function() {
        // Number of seconds to wait before reloading.
        var timeOut = 5;

        setTimeout(function() {
            window.location.reload()
        }, timeOut * 1000);
    };
</script>';

The Wizard


Advertisement: