View Full Version : Resolved Pulling my hair out on this one - jQuery .height()

06-25-2012, 04:24 PM
Hello, everyone.

I have a simple script that is supposed to get the height of all the iframes on a page (three of them) and set all three to the same height (the greatest of the three heights.)

Here's the weird thing. If I put an alert in the script to show me the value(s), it works. If I take out the alert, it doesn't.


Here is my (very simple) code:

var frameArray = document.getElementsByTagName('iframe');
var mH = 0;
for(var j = 0; j < frameArray.length; j++){
if($('#'+frameArray[j].id).height() > mH) { mH = $('#'+frameArray[j].id).height(); }
for(var k = 0; k < frameArray.length; k++){ //alert(mH);
mH = 0;
If the alert is not commented out, it works. If the alert is commented out, it does not work (it does not change the height of any iframe.)



06-25-2012, 04:47 PM
I resolved this by putting the whole thing into a function then applied a setTimeout to the function with a time of 200 ms.

I have another issue that I will be posting about, now.