Hey there everyone
So I have a question that I am sure someone here has the answer to, but no matter how hard I look online, there doesn't seem to be a complete answer as to how to accomplish what I need it to. So I was wondering, how exactly do I prevent the user from going back a page? Let's say that they fight a monster, die, and are shown the screen that says for example "You died n00b, <a href="whatever.php"go back to the index page with less money and half health</a>" (I only included the <a href> tag to show where the link would be. Well my problem is, the user could just say "heh, silly game, I shall now press the back button and try again" and so they do, and nothing is stopping them. So how do I prevent them from doing this? And if I can't deny them from going back a page, how can I make it so that if they try to go back, it just keeps them on the same page they were on before?
Thanks everyone!
Prevent going back [SOLVED]
Prevent going back [SOLVED]
Last edited by 62896dude on Sat Jul 09, 2011 7:59 pm, edited 2 times in total.
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Re: Prevent going back
When i was dealing with fighting etc on my first game i started, i had a flag in the database which indicated whether i was in a fight or not. When a player ran or died, the flag would turn off, and if they tried to go back and do something, they would be sent to another page or a message would display saying they weren't in a fight.
so right at the top of the page you want to run a check to see if this flag is set to on or off, if on then the fight continues, if off then throw them from the page.
I would handle the death consequences the moment they are killed as well so they cant log off and log back on without anything happening.
so right at the top of the page you want to run a check to see if this flag is set to on or off, if on then the fight continues, if off then throw them from the page.
I would handle the death consequences the moment they are killed as well so they cant log off and log back on without anything happening.
New Site Coming Soon! Stay tuned 

Re: Prevent going back
That is a very good idea! I will likely use that in my battles. However, would I just have to do the same thing in every other page? Because I don't think I want the back button used at all
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Re: Prevent going back
i dont quite understand what you mean. I dont think there is anyway of disabling the back button, but you can formulate alot of restrictions using that method.
setting up flags (or a single field which indicates the players current status, such as in battle, cooking, flying etc) can force people to various pages and stopping them from making certain actions while these flags are set.
setting up flags (or a single field which indicates the players current status, such as in battle, cooking, flying etc) can force people to various pages and stopping them from making certain actions while these flags are set.
New Site Coming Soon! Stay tuned 

Re: Prevent going back
Okay, I'll just make it work with the way you showed me then, thanks for the help! 

Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny