Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts

    Pulling my hair out on this one - jQuery .height()

    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:
    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,
    Last edited by WolfShade; 06-25-2012 at 03:48 PM.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    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,
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •