【问题标题】:refresh iframe from inside itself with different domains [duplicate]使用不同的域从内部刷新 iframe [重复]
【发布时间】:2013-06-22 04:56:31
【问题描述】:

我有一个网页,其中包含来自不同域的 iFrame。 现在我在 iFrame 中有一个按钮,按下时需要刷新或重新加载 iframe。

我尝试了一些由于跨域尝试而被阻止的方法..

【问题讨论】:

  • 您实际上尝试过什么?按钮调用 JS 代码是否包含在 iframe 的文档中?
  • window.location.reload() ?
  • 我不同意这个问题与stackoverflow.com/questions/2064850/… 重复,因为这个问题专门关于从 iframe 中的文档重新加载,而另一个问题是关于从包含 iframe 的父文档重新加载。

标签: javascript jquery html cross-domain cross-domain-policy


【解决方案1】:

在 iframe 中的脚本中,试试这个:

document.location.href = document.location.href;

您无法从 iframe 中访问文档模型之外的元素,包括访问 iframe 本身。但是,您可以在其中访问文档的属性。

【讨论】:

  • 为我解决了一个类似的问题,我在 iframe 中的同一域中有一个表单,但在 IE 11 中没有重新加载,当我看到时我已经处理了一个多小时这和我有一个尤里卡!时刻(嗯,好吧,这并没有那么戏剧化,但在原本沉闷的周一工作中,这是一个亮点)
  • 这对我从 iframe 内部重新加载 iframe 很有用。
猜你喜欢
  • 1970-01-01
  • 2010-12-12
  • 2011-11-03
  • 2012-09-04
  • 2019-06-10
  • 1970-01-01
  • 2012-05-24
  • 2011-12-18
  • 1970-01-01
相关资源
最近更新 更多