Refresh IFRAME every few seconds using JavaScript or jQuery

Adnaan
 
on Jul 06, 2012 10:09 AM
32111 Views

Hi,

I want to refresh IFRAME every 5 seconds using jQuery or JavaScript

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mudassar
 
on Jul 06, 2012 10:09 AM
on Jul 06, 2012 10:11 AM
Using jQuery<br />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    setInterval(refreshIframe1, 5000);
    function refreshIframe1() {
        $("#Frame1")[0].src = $("#Frame1")[0].src;
    }
</script>
<iframe id="Frame1" src="https://www.aspforums.net" frameborder="0"></iframe>
<hr />Using JavaScript<br />
<script type="text/javascript">
    setInterval(refreshIframe2, 5000);
    function refreshIframe2() {
        var frame = document.getElementById("Frame2");
        frame.src = frame.src;
    }
</script>
<iframe id="Frame2" src="https://www.aspforums.net" frameborder="0"></iframe>

Demo