SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery script compability problem in chrome only and in specific page

    hello

    in a wordpress site a inserted jquery script to dynamicly expand the colums heights according to the highest one

    Code:
    <script type="text/javascript">
    $(document).ready(function() {
    var colHeight = Math.max($('#c2').height(), $('.widget').height());
    $('#c2, .widget').height(colHeight);
    });
    </script>
    i have a weired problem in this page only and only on chrome (what i saw until now ): http://z-ls.info/category/%D7%A7%D7%...8%D7%99%D7%9D/

    more than that if i access to this page by not directly for example going to another page and then press back, the page apper great

    i hope someone can help with that.

  2. #2
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What's the problem? I tried comparing the page in Chrome, Firefox, and IE, but couldn't find anything...
    I'm the web overlord for Graphic Business Systems

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know something crazy
    but it only when you access the link directly
    and only in chrome screenshot attached

    chrome.png

  4. #4
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Here's my guess as to what's happening... You have some JS for setting #c2 and .widget to be equal height. This code is inside a $(document).ready() function. But jQuery's "ready" function tries to execute as quickly as it can--as soon as the DOM is loaded (it doesn't wait for external resources, like images). So when the user first visits your site, it takes a little longer to first load those images, and jQuery notices that the DOM is finished loading waaay before the images are done. It runs your "equal height" script; when the images do finally finish and show up, they push everything in that column down.

    This would explain why it only happens when the user first visits the page: On subsequent visits, the images are in the cache and can be loaded instantly.

    But I have no idea if this is actually what's happening. The fact that it only happens in Chrome is distressing.

    Easy enough to check, though! If I'm right about what's going on, then the fix would be to have your "equal height" script run when the window is loaded, rather than when the document is ready:

    Code JavaScript:
    $(window).load(function () {
        var colHeight = Math.max($('#c2').height(), $('.widget').height());
        $('#c2, .widget').height(colHeight);
    });

    Does that fix the problem?
    I'm the web overlord for Graphic Business Systems

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just last question

    so what's the diffrence between "window.load" and "document.load"
    why not using windows.load all the time ?

  6. #6
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    God help me how much I love you
    simply genius

    thanks a lot !

  7. #7
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    $(window).load will wait for the entire page to finish loading. Images, frames, video, flash... everything. A lot of the time, you don't really care about that stuff. Usually, your script only needs to wait for particular DOM elements to be available. That's when you would use $(document).ready.
    I'm the web overlord for Graphic Business Systems

  8. #8
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the help and the info


Bookmarks

Posting Permissions

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