一。js实现刷新两种方式:
//方法1 document.getElementById('FrameID').contentWindow.location.reload(true); //方法2 document.getElementById('youriframe').src=src;
实例:
<iframe id="myframe" width="100%" frameBorder="0" src="test.html" 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>
二。jquery实现强制刷新
$('#iframe').attr('src', $('#iframe').attr('src'));
总结:网上一大堆document.frames('ifrmname').location.reload()已经不能用了
转载请注明:半叶寒羽
» js/jquery中刷新iframe方法(兼容主流)