All-in-one location/hashchange history management library

前端 未结 7 518
礼貌的吻别
礼貌的吻别 2020-12-23 13:55

First of all, I know there\'s libraries that provide polyfills for location.pushState/popState (History.js, Hash.js, jQuery hashchange), so please

7条回答
  •  天涯浪人
    2020-12-23 14:30

    I currently use PathJS in one of my applications. It has been the best decision that i have made. For your particular usecase take a look at HTML5 Example.

    The piece of code that that makes the example work (from the source):

    
    

    PathJS has some of the most wanted features of a routing library:

    • Lightweight
    • Supports the HTML5 History API, the 'onhashchange' method, and graceful degredation
    • Supports root routes, rescue methods, paramaterized routes, optional route components (dynamic routes), and Aspect Oriented Programming
    • Well Tested (tests available in the ./tests directory)
    • Compatible with all major browsers (Tested on Firefox 3.6, Firefox 4.0, Firefox 5.0, Chrome 9, Opera 11, IE7, IE8, IE9)
    • Independant of all third party libraries, but plays nice with all of them

    I found the last too points most attractive. You can find them here

    I hope you find this useful.

提交回复
热议问题