Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Reload iFrame Every Few Seconds (10 or 5) using JavaScript

Apr 24, 2013
Introduction

Here I will explain how to refresh or reload iframe every few (10 or 5) seconds using
jQuery or JavaScript. By using jQuery setInterval function we can refresh or reload iframe every few seconds using jQuery or JavaScript.

Description:
  
In previous post I explained jQuery allow only alphabets in textbox, jQuery set interval function example,
split the string using split function in jquery and many articles relating to code snippets, JQuery, JavaScript. Now I will explain how to refresh or reload iframe every few seconds using jQuery or JavaScript.

Check below methods to refresh or reload iframe for every few seconds

jQuery Method


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Reload iframe for every 5 seconds</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
setInterval(refreshiframe, 5000);
});
function refreshiframe() {
$('#testframe').attr('src', $('#testframe').attr('src'));
}
</script>
</head>
<body>
<div>
<iframe id="testframe" src="http://www.aspdotnet-suresh.com" width="350px" height="350px"></iframe>
</div>
</body>
</html>
JavaScript Method


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JavaScript Reload iframe for every 5 seconds</title>
<script type="text/javascript">
function refreshiframe() {
var oElem = document.getElementById("testframe");
oElem.src = oElem.src;
}
</script>
</head>
<body onload="setInterval(refreshiframe, 5000);">
<div>
<iframe id="testframe" src="http://www.aspdotnet-suresh.com" width="350px" height="350px"></iframe>
</div>
</body>
</html>

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

6 comments :

Unknown said...

One problem with code of jquery that if i use code for HTML controls it gets fired but same code for ASP control it is not working..

Suresh Dasari said...

@priya...
if you want to use for asp.net controls you need to change id of calling otherwise asp.net controls won't get identified....

Anonymous said...

ha lya have... :)

Anonymous said...

ha lya have... :)

Alex said...

i got this error

Microsoft JScript runtime error: 'null' is null or not an object

Niyaz said...

plz give your tutosial in serial like jquery besic to advance

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.