2010-08-24 38 views
7

如何使用jquery重新加載iframe?Ajax Reload iframe

<html> 

<head> 
<script type="text/javascript" src="jquery-1.4.2.js" > </script> 


<script type="text/javascript"> 
//Reload Iframe Function  
</script> 

</head> 

<body> 
    <iframe name="f1" id = "f1" src="http://www.google.com.pk/search?q=usa+current+time&ie=utf-8&oe=utf-8&aq=t&client=firefox-a&rlz=1R1GGLL_en" width=500px height=250px> 
    </iframe> 

<button onClick="abc()"> Reload </button> 

</body> 

</html> 

回答

2
$("#reload").click(function() { 
      jQuery.each($("iframe"), function() { 
       $(this).attr({ 
        src: $(this).attr("src") 
       }); 
      }); 
      return false; 
     }); 

通過每次每個的iFrame這將循環您點擊一個鏈接一類reloadAds和iFrame的源設置爲本身

+0

這裏是我的代碼: \t