Reputation: 339
i have page using iframe:
page a.html:
<div id="results">
<iframe src="../b.aspx"></iframe>
</div>
now i want to get elements in iframe, so i try:
<script type="text/javascript">
jQuery(document).ready(function($) {
var tmp = $('#results iframe').contents().find('html').html();
alert(tmp);
});
</script>
but result return is: <head></head><body></body>
, don't have content in head or body. i need a help
Upvotes: 5
Views: 9311
Reputation: 4882
Because your frame is not again loaded..
Try
$("#YOURFRAME").load(function (){
var tmp = $('#results iframe').contents().find('html').html();
alert(tmp);
});
Upvotes: 12