I created the following function to resize the height of an iframe
element always to 100%
after load:
app.directive('iframeAutoSize', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.on('load', function() {
console.log(element[0]);
var iFrameHeight = element[0].contentWindow.document.body.scrollHeight + 'px';
element.css('height', iFrameHeight);
});
}
}}]);
usage:
<iframe iframe-auto-size src="..." />
Problem: I'm getting the following error when launching it:
Error: Permission denied to access property "document"
.
Obviously it's not allowed to execute window.document
on the iframe element. But how could I else find out the height?
I'd prefer a plain angular/js solution without jquery.