1
我有一個ajax web應用程序(JSF 2.0),它使用哈希導航。IE6/7後退/前進按鈕不改變window.location.hash
我已經在this answer和setInterval()
的幫助下使用了事件觸發來檢查舊版瀏覽器(主要是IE6 + 7)的值更改。
的JavaScript代碼,這是否:
window.onload = window.onhashchange = function() {
lastHash = window.location.hash; // To save a refresh on browsers that don't need it.
var fragment = document.getElementById('fragment');
fragment.value = window.location.hash;
fragment.onchange();
}
// Old Browsers That don't support onhashchange...
var lastHash = window.location.hash;
function checkFragment() {
if (window.location.hash != lastHash) {
lastHash = window.location.hash;
var fragment = document.getElementById('fragment');
fragment.value = window.location.hash;
fragment.onchange();
}
}
這工作得很好。意思是,當我改變散列的值時,AJAX應用程序獲取通知和更新。 這不起作用的一個實例是IE 6/7。當我按下「後退/前進」按鈕時,我可以看到url欄使用正確的哈希值更新,但windows.location.hash
似乎沒有更改,所以我的SetEvent()
函數未檢測到更改。
任何人都找到了解決方案? 謝謝!
嗯......看起來像我這樣的JavaScript,而不是Java – 2011-05-06 13:15:00