Bungle
Bungle

Reputation: 19712

How do I refer to an <iframe>'s document using jQuery to get its height()?

I'm trying to get the height of an <iframe>d document. My first instincts were:

$('iframe').document.height();

or

$('iframe').contentWindow.document.height();

Those don't work, and I'm not having much luck searching. I would appreciate any help!

Upvotes: 1

Views: 447

Answers (2)

Delon
Delon

Reputation: 253

Try this out:

$(document).ready(function(){

    $("iframe").bind('mouseover', function(){
        alert($(this).contents().height());
    });

});

Upvotes: 0

Chris Ballance
Chris Ballance

Reputation: 34367

$("iframe",top.document).contents().height();
alert("iframe height=" + $("iframe",top.document).height());

Upvotes: 2

Related Questions