Reputation: 729
I want to set the height of the iframe
match it's content. But iframe.contentWindow
returns undefined
even after putting it inside .load()
. Here's the code:
$(document).ready(function() {
var myIFrame = $('#iframe');
console.log(myIFrame.contentWindow); //getting undefined
});
Can someone tell me what's wrong in this? Thanks a lot.
Upvotes: 1
Views: 4364
Reputation: 729
Alright, so contentWindow
is native Javascript and since I'm using jQuery, I'll have to get the original DOM object first. The correct way to get contentWindow
:
var win = $('#iframe').get(0).contentWindow;
Upvotes: 2