ember.js - Html4 browsers does not support history.pushState and history.replaceState methods of History API from HTML5 -
i working on ember application (using ember-1.0.pre.js). , i'm trying provide cross browser compatibility on ie8.
the issue url generate after every transition, seems incorrect/falsy user. let hit url the_ domain_name/sell/new
land me on sell page of our application. , tries transit new state called "purchase" land me on purchase page of our application.
new state transition generates url the_ domain_name/sell/new#/offers/purchase?&suid=1365149991779013736531657156165
in ie8 addressbar instead of the domain_name/offers/purchase
.
note: the_domain_name = http://www.example.com
the generated url includes 2 incorrect things,
the initial prefix "/sell/new#".
the parameter "?&_suid=1365149991779013736531657156165" in query string of url.
i tried figure out issue , found html4 browsers not supports pushstate , replacestate methods history api html5. how can provide support on ie8 can me on this?
i suggest history.js
polyfill browsers not support history api: https://github.com/browserstate/history.js
it working in:
html5 browsers:
- firefox 4+
- chrome 8+
- opera 11.5
- safari 5.0+
- safari ios 4.3+
html4 browsers:
- ie 6, 7, 8, 9
- firefox 3
- opera 10, 11.0
- safari 4
- safari ios 4.2, 4.1, 4.0, 3.2
add jquery.history.js & register history.js
location handler ember app.
here parts modified original ember.historylocation
( full code )
(function() { var = ember.get, set = ember.set; var popstatefired = false; ember.historyjslocation = ember.object.extend({ initstate: function() { this.replacestate(this.formaturl(this.geturl())); set(this, 'history', window.history); }, getstate: function() { return get(this, 'history').getstate().state; }, pushstate: function(path) { history.pushstate({ path: path }, null, path); }, replacestate: function(path) { history.replacestate({ path: path }, null, path); } }); ember.location.registerimplementation('historyjs', ember.historyjslocation); })();
then use polyfill in app:
app.router.reopen({ location: 'historyjs' });
Comments
Post a Comment