I changed something between last night and this morning and now my back buttons are not working.
I have used
<button type="submit" onClick="history.go(-1)">Back</button>
without a problem up until this morning. Now, when this button is clicked, the previous URL is loaded, but my PHP $_SESSION is not, cause me to be redirected to my login page.
If I use the browsers built-in back button, it loads without any problems.
This problem persists in both FireFox 38.0.5 and IE 11.
I have tried history.go(-1)
, history.back
and a few others and there is something wrong with the JS.
Any ideas what to look out for? I am by no means a JS expert (this is about as much as I do) and my site has virtually no JS in it to begin with.
I'd love to give more code examples, but as I haven't the faintest idea where the problem is, I would only be able to upload my entire system...
Thanks in advanced.
Thank you Vhortex and Hearner!!!
I had accidentally made it type="submit"
instead of type="button"
. So my code should be <button type="submit" onClick="history.go(-1)">Back</button>
Is there any way to delete a post? This is embarrassing...(kidding)
Happy Thursday!
You are forcing your form submit to go back 1 page before the actual "login form". Before submit fires and send data to your PHP form in the server, the browser already loaded 1 page back.
<button onClick="window.history.go(-1);">Back</button>
YOu have many problems in you code : If you want to use type="submit"
you can't use <button>
but <input>
like
<input type="button" value="Back" onClick="window.history.go(-1);" />
Or <button onClick="window.history.go(-1);">Back</button>
The fisrt one is better