【问题标题】:history.replaceState issue with iframesiframe 的 history.replaceState 问题
【发布时间】:2014-10-12 18:05:44
【问题描述】:

我要疯了。我已经阅读了有关该主题的所有内容,但我迷路了...

我有一个带有按钮和 2 个 iframe 的页面。

<input name="showButton" type="button" id="showButton" value="Show" />
<iframe id="messagelistviewframe" src="blank.html"></iframe>
<iframe id="messageviewframe" src="blank.html"></iframe>

单击按钮会更改 2 个 iframe 的 url。

$(document).ready(function () {
    $('#showButton').bind("click", function (e) {
        $('#messagelistviewframe').attr('src', 'red.html');
        $('#messageviewframe').attr('src', 'yellow.html');
    });    
}

不幸的是,这会创建 2 个历史记录条目,每个 iframe url 更改一个。所以点击浏览器的后退按钮,我首先得到一个页面,第二个 iframe 回到原来的 url,如果我再次点击,我得到了两个。

我以所有可能的方式尝试了 history.replaceState,但我认为无济于事。我在 Firefox 上得到了一些结果,但在 Chrome 和 IE 上都没有。

有没有办法让后退按钮直接给我带有原始 iframe url 的原始页面? TIA

【问题讨论】:

    标签: javascript jquery html iframe history


    【解决方案1】:

    终于在Reload an IFRAME without adding to the history这篇文章中找到了答案。诀窍是重新创建 iframe 或将其从 DOM 中删除并重新添加。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-18
      • 2012-10-01
      • 2014-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-25
      相关资源
      最近更新 更多