In one of my applications i use window.history.pushState()
method to update the window URL. But as IE < 10
does not support HTML5's history api, I was looking for an alternative. Answers to a lot of other questions on SO suggested to use history.js
plugin.
From the documentation provided by the history.js plugin it's usage is not really clear. I have added the plugin to the <head></head>
section in my templates but on IE9 i am still receiving the error that says:
SCRIPT438: Object doesn't support property or method 'pushState'
params.js, line 37 character 5
the function that errors out is as follows
/**
* updates the window url according to the given parameters.
*/
function updateUrl(params) {
var path = window.location.pathname;
var url = $.param.querystring(path, params);
url = decodeURIComponent(new_url).replace("#", "", "g");
window.history.pushState(null, null, new_url);
}
You need to initiatialize the History and State variables for it to work.
and now you can use
pushState
method for all browsers as follows: