Using Jquery in an iframe

Although it may not seem like an easy task at first, it is quite possible to use jquery inside of an iframe. The first trick involves loading jquery inside the iframe code itself.

Html Containing Iframe

<html>
<head>
<title>Jquery Iframe Test</title>
<script type='text/javascript' src='javascript/jquery.min.js'></script>
</head>
<body><br /><div id='manip'></div>
<iframe src='jquery-frame.html'></iframe&>
</body>
</html>

Html in Iframe

<html>
<head>
<title>Jquery Iframe Test</title>
<script type='text/javascript' src='javascript/jquery.min.js'></script>
<script type='text/javascript' src='custom.js'></script>
</head>
<body>
</body>
</html>

custom.js source Code

$(document).ready(function(){
$(window).parent("#manip").html("test");
});
ttessier

About ttessier

Professional Developer and Operator of SwhistleSoft
This entry was posted in Html, Javascript Development, Web Development and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *