Any way to detect a back or refresh?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Any way to detect a back or refresh?

Post by Citizen »

I've searched for about 30 mins and cant find anything on it.

I'm making a web based game and was wondering if there was a way to detect if a user clicks back or refresh in a browser.

Any ideas?

Thanks.
Z3RO21
Forum Contributor
Posts: 130
Joined: Thu Aug 17, 2006 8:59 am

Post by Z3RO21 »

on a page check to see if the session var $_SESSION['MySessionVar'] exists and if it doesn't set it and if it does exist then they have either refreshed or navigated back to the page
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Post by Citizen »

I want them to be able to visit the page more than once, but only if they use the navigation system and not browser controls.
User avatar
Cameri
Forum Commoner
Posts: 87
Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic

Post by Cameri »

You could use AJAX, and instead of loading a new page, just retrieve the content the user requests, that way the back button is useless
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Cameri wrote:You could use AJAX, and instead of loading a new page, just retrieve the content the user requests, that way the back button is useless
If you're doing AJAX properly then the back button should still work.
User avatar
Cameri
Forum Commoner
Posts: 87
Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic

Post by Cameri »

If you use the AJAX tecnique with iframes, then you can still use the back buttons, but if you use the XmlHttp object, then you shouldnt be able to go back unless you REALLY came from another page.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Cameri wrote:If you use the AJAX tecnique with iframes, then you can still use the back buttons, but if you use the XmlHttp object, then you shouldnt be able to go back unless you REALLY came from another page.
Nope. If you use an XmlHttp request you should still be able to use the back button. It's a fundamental aspect of accessibility. http://www.onjava.com/pub/a/onjava/2005 ... utton.html
Post Reply