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.
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. |
|||
|
|||
6 comments :
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..
@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....
ha lya have... :)
ha lya have... :)
i got this error
Microsoft JScript runtime error: 'null' is null or not an object
plz give your tutosial in serial like jquery besic to advance
Note: Only a member of this blog may post a comment.