JS、jQuery 刷新 iframe 的方法

1、JavaScript 刷新 iframe 可以使用以下方法:

document.getElementById('some_frame_id').contentWindow.location.reload();

实例:

<iframe id="myframe" width="100%" frameBorder="0" src="https://www.runoob.com scrolling="no"></iframe>
<input type="button" onclick="javascript:refreshFrame();" value="Refresh Frame" /> 

<script type="text/javascript">
<!--
function refreshFrame(){
document.getElementById('myframe').contentWindow.location.reload(true);
}
-->
</script>

2、jQuery 刷新 iframe 可以使用以下方法:

$('#iframe').attr('src', $('#iframe').attr('src'));
posted @ 2020-07-07 22:15  王永杰的网络日志  阅读(296)  评论(0编辑  收藏  举报