diff --git a/backbone.js b/backbone.js index d10093d63..1a0ebae3e 100644 --- a/backbone.js +++ b/backbone.js @@ -851,7 +851,7 @@ // Handles cross-browser history management, based on URL fragments. If the // browser does not support `onhashchange`, falls back to polling. - Backbone.History = function() { + var History = Backbone.History = function() { this.handlers = []; _.bindAll(this, 'checkUrl'); }; @@ -863,10 +863,10 @@ var isExplorer = /msie [\w.]+/; // Has the history handling already been started? - var historyStarted = false; + History.started = false; // Set up all inheritable **Backbone.History** properties and methods. - _.extend(Backbone.History.prototype, Backbone.Events, { + _.extend(History.prototype, Backbone.Events, { // The default interval to poll for hash changes, if necessary, is // twenty times a second. @@ -892,10 +892,11 @@ // Start the hash change handling, returning `true` if the current URL matches // an existing route, and `false` otherwise. start: function(options) { + if (History.started) throw new Error("Backbone.history has already been started"); + History.started = true; // Figure out the initial configuration. Do we need an iframe? // Is pushState desired ... is it available? - if (historyStarted) throw new Error("Backbone.history has already been started"); this.options = _.extend({}, {root: '/'}, this.options, options); this._wantsHashChange = this.options.hashChange !== false; this._wantsPushState = !!this.options.pushState; @@ -903,6 +904,7 @@ var fragment = this.getFragment(); var docMode = document.documentMode; var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7)); + if (oldIE) { this.iframe = $('