2014-03-12 44 views
0

我的代码自动刷新iframe无法正常工作?

<iframe src="http://www.w3schools.com" name="isfsf"> 
</iframe> 

<script> 
window.setInterval("reloadIFrame();", 3000); 

    function reloadIFrame() { 
    document.frames["isfsf"].location.reload(); 
} 
</script> 

自动刷新的iframe不工作?请帮我

+0

更改window.setInterval( “reloadIFrame();”,3000); to window.setInterval(function(){reloadIFrame();},3000); – Koti

回答

0

试试这个:

function refresh() 
{ 
    var iframe = document.getElementById('iframe'); 
    iframe.reload(true); 
} 

setTimeout('refresh()', 3000); 
0

试试这个

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

document.getElementById('isfsf').src = document.getElementById('isfsf').src; 
1

试试这个。为了在代码之下工作,不要忘记包含jquery库。 其将刷新iframe标签以每3秒

$(document).ready(function() { 

setInterval(function(){ 

     var url=$('iframe').attr('src'); 
     $('iframe').attr('src',url); 

},3000); 


}); 
1

尽量做到:

window.setInterval(function(){ reloadIFrame() },3000); 

function reloadIFrame() { 
    document.getElementById('isfsf').contentWindow.location.reload(); 
}