如何刷新 iframe? 例如:
<iframe src="http://google.com"></iframe>
我点击这个 iframe 中的“视频”,然后点击一个按钮来刷新 iframe,我希望当 iframe 刷新时,出现在那个“视频”页面上。
最佳答案
由于单源策略,您无法刷新其中的内部文档。
您是否尝试过更改 iframe 的 src
属性并添加随机 GET 字符串以强制重新加载?
这应该有效:
<iframe id="myiframe" src="http://google.com"></iframe>
document.getElementById("myiframe").src = "http://www.google.com?"+(+new Date());
关于javascript - 刷新 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3244877/