0

假设我有一个带有 Web 资源的表单,当查看表单并单击 Web 浏览器的“后退”按钮时,Web 资源似乎已卸载,如果我再次单击后退按钮,那么它的行为与我预期的一样。

有没有其他人经历过这个?当用户单击“返回”时,有没有办法阻止 Web 资源卸载?

注意:这似乎发生在 IE (10,11) 和 Chrome 中,但不是 Firefox。

4

1 回答 1

0

有同样的问题,看起来像一个错误。在 Microsoft 修复它之前,请在您的网络资源中使用以下内容来捕获返回事件并正确重定向它。

$(document).ready(function () {
if (window.history && window.history.pushState) {
    $(window).on('popstate', function () {
        var hashLocation = location.hash;
        var hashSplit = hashLocation.split("#!/");
        var hashName = hashSplit[1];
        if (hashName !== '') {
            var hash = window.location.hash;
            window.parent.history.back();
            window.parent.history.back();
        }
    });
    window.history.pushState('forward', null, './#forward');
}

}

于 2013-12-19T19:00:14.493 回答