Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Thursday, 9 April 2015

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.

Following code is used to reload 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>
Categories: , ,

0 comments:

Post a Comment