refreshing back page

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

refreshing back page

Post by dude81 »

Hello
How do we do refresh the back page on clicking Back button of the browser tool bar.
I tried on

Code: Select all

onunload='window.location.reload()".
it didnt work
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hmm... you wouldn't do it in the current page... you need the JS in the page you're going back to.

Perhaps passing a GET var and then using php to do something like

Code: Select all

if (isset($_GET['refresh']))
{
    echo <<<SCRIPT
<script type="text/javascript">
<!-- Hide
window.location = '{$_SERVER['PHP_SELF']}'; //Drop the GET var and just reload
// -->
</script>
SCRIPT;

}
Perhaps there's a pure JS way to do it by looking at the history property.....
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I don't believe it can be done. You can put php headers at the top of the page to force a fresh copy with every new load but forcing a refresh by using the back button would require modification of the browser settings which (for *good* security reasons), can't be done.

One way I've gotten around it is to force the user back to the current page when they click back and provide a link to the previous page. This will force a page reload and accomplish what you're after. The biggest drawback is that some people get confused when they try to click back and it goes no where. I've therefore put a section of text at the top of my page that says "The back button on your browser will not work, Click here to go back" kinda thing....
Post Reply