私のアプリケーションの 1 つで、window.history.pushState()
メソッドを使用してウィンドウの URL を更新します。しかし、IE < 10
HTML5 の履歴 API をサポートしていないため、代替手段を探していました。SOに関する他の多くの質問への回答は、history.js
プラグインの使用を提案しています。
history.js プラグインによって提供されるドキュメントから、その使用法は明確ではありません。テンプレートのセクションにプラグインを追加しました<head></head>
が、IE9 ではまだ次のようなエラーが表示されます。
SCRIPT438: Object doesn't support property or method 'pushState'
params.js, line 37 character 5
エラーになる関数は次のとおりです
/**
* 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);
}