JS/jQuery 刷新 iframe 的方法

约 516 字 更新于 2026-11-18 5iyo.com

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