Using history.pushstate in IE9

前端 未结 4 1342
逝去的感伤
逝去的感伤 2020-12-17 06:48

Since window.history.pushState is not aviliable for HTML 4 browsers like IE9 , I have looked for history.js, a jQuery library that simulates the pushState behavior.

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-17 07:37

    You need to set up a client-side redirect for IE. Assuming the user lands at this page:

    http://localhost/development/flipV5.html?issue=20121220&page=1
    

    They need to be sent to

    http://localhost/development/flipV5.html#?issue=20121220&page=1
    

    The reason is that IE <= 9 doesn't let you modify anything before the hash, without sending the user to a new page. It's an old security feature preventing changing the URL to facebook.com, when you're really on spambook.com. Recently, people have realized that that's overkill.

    The redirect looks like this:

    
    

    You can now push states, and they won't show up in both the search and the hash (that's after the ? and # respectively)

提交回复
热议问题