JavaScript JS/jQuery 刷新 iframe 的方法

hilton · 2022-04-20 21:43:28 · 热度: 81

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

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

实例:

<iframe id="myframe" width="100%" frameBorder="0" src="https://www.codercto.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'));

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册