Back button not updating hash in iframe on IE

久未见 提交于 2019-12-25 05:13:43

问题


I have an application that uses a combination of the onhashchange event (for new browsers) and the hashchange plugin by Ben Alman (for old browsers) to track the history while making ajax calls or actions. Works like a charm in all browsers, back and forward buttons let the user navigate the actions that get recorded by changing the hash. So far so good. Now our page will be hosted in an iframe on a clients page in a diff domain(cross domain). Chrome kind of works but if you put to many changes in the history it stops working at some point (we can live with that). IE dosen't work at all. When I navigate our application by clicking on links and updating the hash new history items get created in the parent page but when I hit the back button the hash in the nested page is not updated therefore the hashchange event never fires. Anyone solved this problem before? Many thanks

Initialize the hash change event handling

if ("onhashchange" in window && !($j.browser.msie && $j.browser.version == '7.0')) {
    window.onhashchange = function() {
        var params = parseHash(location.hash)

        if (params.tabId) {
            if (getSelectedTabId() == params.tabId) return;
            reloadPage(params.tabId);
        }
    };
}
else {// Plugin for older browsers
    $j(window).bind('hashchange', function() {            
        var params = parseHash(location.hash)
        if (params.tabId) {
            if (getSelectedTabId() == params.tabId) return;
            reloadPage(params.tabId);
        }
    });
}

来源:https://stackoverflow.com/questions/10822544/back-button-not-updating-hash-in-iframe-on-ie

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!