...

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



WolfShade
06-25-2012, 03: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.

WTF???

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);
$('#'+frameArray[k].id).height(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.)

Thoughts?

Thanks,

WolfShade
06-25-2012, 03: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.

Thanks,



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum