1

For IE, versions lower then 10, I made a fallback, so the router is not using the pushState, but the hashchange. The initialize method of the router looks like this:

initialize: function(){
   var self = this;
   Backbone.history = Backbone.history || new Backbone.History({});
   var root = "/";

   Backbone.history.start({
    pushState: Modernizr.history,
    root: root,
    silent: !Modernizr.history
   }); 

   // handle history for old internet explorer
   if(!Modernizr.history) {
    var rootLength = Backbone.history.options.root.length;
    var fragment = window.location.pathname.substr(rootLength) || 'cs';
    self.navigate(fragment, { trigger: true });
   }
  }

Like this the router is working fine both for old IE and for modern browsers, but in IE if the original url looks like this -> http://example.com/lang/page , then the router is navigating to http://example.com/lang/page#lang/page. Is it possible to navigate on first load to http://example.com#lang/page and if it is how to achieve that? Many thanks for your answers!

hjuster
  • 3,985
  • 9
  • 34
  • 51
  • Ever thought of something like `if (location.pathname != '/' && !history.pushState) { location.href = '/#' + location.pathname.slice(1); }` ...? It's almost a literal translation of your requirement to code. – Rob W May 26 '14 at 11:58
  • But i guess then the page will reload and I want just the router to navigate without the refresh.... – hjuster May 26 '14 at 12:06
  • You cannot change the URL without reload in old IE. – Rob W May 26 '14 at 12:11

0 Answers0