【问题标题】:iframe src is not changing when I click back button当我点击后退按钮时,iframe src 没有改变
【发布时间】:2015-09-05 16:42:54
【问题描述】:
 <iframe id ="iframeA" name="iframeA" src="./friendList.html" frameborder="0" width="100%" height="100%"></iframe>

我有一个这样的 iframe 标签。当父框架加载时,我在这个 iframe 正文中添加了一些标签。但是,当我使用 jquery 将 iframe src 更改为 './letterList.html' 时,将会正确加载 letterList.html,然后当我单击后退按钮时,iframe src 不会更改为原始 './friendList.html'(甚至焦点在 iframe) 中,但 iframe 中的内容是 './friendList.html' 的内容。只有 src 没有改变。当然,我在 iframe 正文中添加的标签也不见了。我知道标签不见了,但我不明白为什么 src 没有更改,但 iframe 中的内容是原始 iframe 的内容。 有人可以帮我吗?.....

【问题讨论】:

    标签: javascript jquery html iframe src


    【解决方案1】:

    不知道你的意思是“为什么”。这不是错误,这是specified 行为(查看name 属性描述之前的注释)。这样做可能是因为 iframe 有时根本无法与父文档交互。
    但是,如果您想处理这个问题,您可能会在 iframe 中捕获 onbeforeunload 事件并重置其 src

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-30
      • 2022-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-10
      相关资源
      最近更新 更多