From c9d66ec3e9839a325363f074e800b09353ca0003 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 24 Jun 2014 15:31:02 +0200 Subject: [PATCH] Make sure H5Ps work in nested iframes. --- js/h5p.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index f0860e5..3b5db69 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -38,7 +38,7 @@ H5P.init = function () { H5P.$body = H5P.jQuery(document.body); // Prepare internal resizer for content. - var $window = H5P.jQuery(window.top); + var $window = H5P.jQuery(window.parent); // H5Ps added in normal DIV. var $containers = H5P.jQuery(".h5p-content").each(function () { @@ -92,7 +92,7 @@ H5P.init = function () { // Make it possible to resize the iframe when the content changes size. This way we get no scrollbars. var iframe = window.parent.document.getElementById('h5p-iframe-' + contentId); var resizeIframe = function () { - if (window.top.H5P.isFullscreen) { + if (window.parent.H5P.isFullscreen) { return; // Skip if full screen. } @@ -122,7 +122,7 @@ H5P.init = function () { // Resize everything when window is resized. $window.resize(function () { - if (window.top.H5P.isFullscreen) { + if (window.parent.H5P.isFullscreen) { // Use timeout to avoid bug in certain browsers when exiting fullscreen. Some browser will trigger resize before the fullscreenchange event. instance.$.trigger('resize'); }