Using HTML5 pushState() in IE9

前端 未结 2 1671
情话喂你
情话喂你 2020-12-09 15:26

Is there any way to use HTML5 History API (pushState) in IE9? If there is a solution for all other browsers that would be great!

2条回答
  •  有刺的猬
    2020-12-09 16:29

    As per Ember documentation about history api: http://emberjs.com/api/classes/Ember.Location.html

    Browsers that support the history API will use HistoryLocation, those that do not, but still support the hashchange event will use HashLocation, and in the rare case neither is supported will use NoneLocation.

    App.Router.map(function() {
      this.resource('posts', function() {
        this.route('new');
      });
    });
    
    App.Router.reopen({
      location: 'auto'
    });
    

    This will result in a posts.new url of /posts/new for modern browsers that support the history api or /#/posts/new for older ones, like Internet Explorer 9 and below.

    When a user visits a link to your application, they will be automatically upgraded or downgraded to the appropriate Location class, with the URL transformed accordingly, if needed.

提交回复
热议问题