How to make browser back and forward work on a single page layout?

后端 未结 3 2001
深忆病人
深忆病人 2021-01-01 04:35

As a follow-up question to: Most efficient way to do a horizontal sliding layout, is it possible to make the browser\'s back and forward button work when using a single page

3条回答
  •  甜味超标
    2021-01-01 04:52

    You can use the history API in HTML5 to achieve that.

    Here are a few resources to get you started:

    • http://diveintohtml5.info/history.html
    • http://html5demos.com/history
    • https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history

    To get support in older browsers as well, there are JavaScript libraries that enable that:

    • https://github.com/browserstate/History.js/

    Advanced example by the Chrome team, that uses the history API:

    • http://www.20thingsilearned.com/en-US

提交回复
热议问题