Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

one page web app, back button takes me to login screen

I have a webapp which uses a lot of Jquery
there are essentially 2 pages
1. login page
2. main page

the main page contains many tabs and it acts as if its going to different pages, but its all one page

the issue i have is the back button takes me to the login page
I would like it to store the tab navigation, and navigate based on where i've been

is this possible, of so how?
Avatar of Gauthier
Gauthier

yes, history.pushState
There are also some (very buggy) plugin for jquery which attempt to make it compatible with older browsers:
such as https://github.com/browserstate/history.js/
Avatar of websss

ASKER

thanks
I'm not bothered about supporting old browsers, just HTML 5 compliant ones
can i just call history.pushState on tab clicks?

or do i need to reference a js file that isn't native to HTML5 ?
Note that IE9 doesn't support history.pushState
If you decide to use the html5 way, just use
history.pushState and a listener on popstate.
Be carefull of your urls, pushState let you make them up with no server backing.
But think of bookmarking, hard refresh, SEO. What you can do is constrained by your framework (URL rewrite) server side, you may need to use # to make it simpler.
here is a simple sample:
http://html5.gingerhost.com/london
Avatar of websss

ASKER

thanks man
Its a web app which is used internally

Therefore SEO isn't and issue, and we dont have to worry about IE9

So can i literally call history.pushState on button click?
ASKER CERTIFIED SOLUTION
Avatar of Gauthier
Gauthier

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial