Strange jQuery $ (window) .load () behavior in Safari

I have a page loading at <iframe>.

Inside <iframe>, I have a function that patiently waits for a page to load using the jQuery event $(window).load(), which should wait until ALL the contents of the page (images, javascript, css, etc.) are loaded before firing.

The function then accesses the page, loading <iframe>with postMessageto send the height of the content in <iframe>back.

I tested the functionality in IE7, IE8, Firefox 2, Firefox 3, Opera and Chrome, and everything works fine. When I try to load a page in Safari, the function calls back before the images are loaded ... this way I get the wrong page height.

Does anyone know how to make Safari wait for images to load before calling the function (in this case jQuery solutions are preferred)?

+3
source share
1 answer

Checking the bias forces the safari to complete loading / linking of content, it blocks javascript until the return is complete. You can use it as follows:

$(window).load(function() {
  var block = document.body.offsetWidth;
  //Rest of code...
});
+5
source

Source: https://habr.com/ru/post/1738713/


All Articles