We're writing a web app to act as a control panel for our back end, we're solely using JavaScript - All DOM elements are created dynamically, no static HTML at all.
We have a module/plugin type interface, a module is a collection of "views" - A view is essentially a function that contains an initialize method which accepts an arg of a div so it knows where to draw itself.
As a user browses between views, we maintain a history of where they've been and where they are etc. so we can provide back/forward navigation between views as well as saving the state of the views as they navigate.
We provide a breadcrumb trail as well as back and forward buttons. What I'd also like to do is hook the browser back/forward buttons so we can intercept clicks and override it so it browses through the history we're maintaining - When they get to the very first pag开发者_开发问答e of the history we're maintaining we would of course not override and let them navigate away from our site.
Is there a common way to do this? Or do browsers explicitly prevent this sort of thing?
Thanks
Use Ben Alman's great jQuery-bbq plugin: http://benalman.com/projects/jquery-bbq-plugin/ which provides a hashchange cross-browser that is used in conjunction with back/forward buttons.
精彩评论