mirror of
https://github.com/silverstripe/silverstripe-iframe
synced 2024-10-22 11:05:51 +02:00
commit
2705bc1fda
@ -9,26 +9,27 @@ if (typeof jQuery!=='undefined') {
|
|||||||
iframe.hide();
|
iframe.hide();
|
||||||
loading.show();
|
loading.show();
|
||||||
|
|
||||||
$(function() {
|
$( iframe ).on('load', function() {
|
||||||
$( window ).load(function() {
|
// Iframe content has been loaded
|
||||||
// Iframe content has been loaded
|
loading.hide();
|
||||||
loading.hide();
|
iframe.show();
|
||||||
iframe.show();
|
|
||||||
|
|
||||||
if (iframe.hasClass('iframepage-height-auto')===true) {
|
if (iframe.hasClass('iframepage-height-auto')===true) {
|
||||||
// Try to set the height to the height of the iframe content (only possible if it is the same domain)
|
// Try to set the height to the height of the iframe content (only possible if it is the same domain)
|
||||||
try {
|
try {
|
||||||
var iframeInsideSize = $(iframe[0].contentWindow.document.body).height();
|
// Use plain JS to get iframe size. There is some timing issue with jQuery
|
||||||
iframe.css('height', (parseInt(iframeInsideSize)+100)+'px');
|
// which causes the iframe size to be 0 even after iframe.show().
|
||||||
}
|
const domframe = document.querySelector('#Iframepage-iframe');
|
||||||
catch(e) {
|
var iframeInsideSize = domframe.contentWindow.document.body.offsetHeight;
|
||||||
// Failed to set the height, we fall back to default css height.
|
iframe.css('height', (parseInt(iframeInsideSize)+100)+'px');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch(e) {
|
||||||
|
// Failed to set the height, we fall back to default css height.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, remove the marker
|
// Finally, remove the marker
|
||||||
iframe.removeClass('iframepage-not-ready');
|
iframe.removeClass('iframepage-not-ready');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user