How do I get the previous page with javascript on phonegap?
I want to go back (window.history.back()
) only if I come from one specific html file, otherwise I want to go to another html page when back button is pressed.
So I want to know which one is the previous page on history.
I have been googling for a while and I didn't find an answer that suits for me.
If you want something built in you can use
document.referrer
to get the previous URL. But it might not be reliable for your needs. More info here, here and hereAnother VERY simple option is to store the current page name in the session storage, read it and then decide what to do next.
LocalStorage vs SessionStorage