NOTENotes & quizzesFETCHED

JS/jQuery 刷新 iframe 的方法

1、JavaScript 刷新 iframe 可以使用以下方法: document.getElementById('some_frame_id').contentWindow.location.reload(); 实例:..

Updated 7/16/2026

Tutorial detail pages default to noindex.

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'));