diff --git a/public/js/grocy.js b/public/js/grocy.js index c9cba036..cf8fa925 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -554,9 +554,27 @@ ResizeResponsiveEmbeds = function(fillEntireViewport = false) } $("embed.embed-responsive").attr("height", maxHeight.toString() + "px"); + ResizeIframes(); +} +ResizeIframes = function() +{ $("iframe.embed-responsive").each(function() { - $(this).attr("height", $(this)[0].contentWindow.document.body.scrollHeight.toString() + "px"); + var desiredHeight = $(this)[0].contentWindow.document.body.scrollHeight; + if (desiredHeight == 0) + { + // The corresponding frame should be loaded after the "onload" event fired, + // this seems to be sometimes (not really reproducible) not the case in Chrome based Browsers... + // => So if that happens, just try this again later + setTimeout(function() + { + ResizeIframes(); + }, 200); + } + else + { + $(this).attr("height", desiredHeight.toString() + "px"); + } }); } $(window).on('resize', function()