views:

129

answers:

1

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!

+2  A: 
$("iframe",top.document).contents().height();
alert("iframe height=" + $("iframe",top.document).height());
Chris Ballance
Thanks Chris, but that didn't work for me (at least in Firefox). I get this exception:[Exception... "Could not convert JavaScript argument arg 0" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js :: anonymous :: line 12" data: no]If I assign that to a variable as such:var height = $("iframe", top.document).contents().height();it remains undefined after the assignment and causes the above exception.
Bungle
Also, this:$("iframe", top.document).height();appears to just give me the height of the <iframe>, not the document that it contains. I just realized that I might have missed an important detail, or at least have been unclear - I'm trying to get this height from the parent document of the <iframe>, not from within the <iframe> itself.
Bungle