Introduction:
Sometime
it is needed to show other website in Iframe and refresh it on button click. We
can do it using jQuery easily. Using jquery events we can refresh the Iframe on
button click event. In
this article I will explain how to refresh iframe using jQuery.
<script type="text/javascript">
$(function
() {
$('#btnRefresh').click(function () {
$('#testframe').attr('src', $('#testframe').attr('src'));
});
});
</script>
Full source Code for Sample Application:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Reload iframe</title>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function
() {
$('#btnRefresh').click(function () {
$('#testframe').attr('src', $('#testframe').attr('src'));
});
});
</script>
</head>
<body>
<div>
<iframe id="testframe"
src="http://www.maziksolutions.com"
width="400px"
height="350px"></iframe><br /><br />
<input type="submit"
name="go"
id="btnRefresh"
value="Refresh
Iframe"/>
</div>
</body>
</html>
0 comments:
Post a Comment