iframe引入的页面跳转之后刷新一下iframe
时间: 2023-08-31 18:12:42
浏览: 139
如果你想在 iframe 中加载的页面跳转后重新刷新 iframe,可以使用 JavaScript 中的 loc[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)on.reload() 方法。当 iframe 中的页面跳转时,可以在父[窗口](https://geek.csdn.net/educolumn/00d3d1b467be187bf63895f811603770?spm=1055.2569.3001.10083)中监听 iframe 的 load 事件,然后在事件处理程序中调用该方法实现刷新。
以下是示例代码:
```html
<iframe id="myFrame" src="http://example.com"></iframe>
<script>
var myFrame = document.getElementById('myFrame');
myFrame.onload = function() {
// 监听 iframe 的 load 事件
myFrame.content[window](https://geek.csdn.net/educolumn/03e5a5a554174a38fdfeb8376bd685e2?spm=1055.2569.3001.10083).loc[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)on.reload();
</script>
在上面的代码中,我们首先获取了 ID 为 myFrame 的 iframe 元素,然后在 onload 事件处理程序中监听了 iframe 的 load 事件。当 iframe 中的页面加载完毕后,我们调用了 content[window](https://geek.csdn.net/educolumn/03e5a5a554174a38fdfeb8376bd685e2?spm=1055.2569.3001.10083).location.reload() 方法,该方法可以刷新 iframe 中的页面。
相关推荐


















