I'm building a dialog whose content is an iframe. When the dialog opens I have the following code that I pulled from various sources in attempting to make this work:
var iframeDOM = document.createElement("IFRAME");
iframeDOM.setAttribute("frameborder", "0");
iframeDOM.setAttribute("scrolling", plugin.settings.scrolling ? "" : "no");
iframeDOM.setAttribute("allowtransparency", isIE ? "true" : "");
var setDimensions = function(){
console.log("load");
var iframeWin = iframeDOM.contentWindow || iframeDOM.contentDocument.parentWindow;
if (iframeWin.document.body) {
console.log("new height: " + iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight); //Not giving real height, always 0
console.log("new client height: " + iframeWin.document.documentElement.clientHeight);
iframeDOM.height = 550;
iframeDOM.width = 550;
}
};
$(iframeDOM).load(setDimensions)
.appendTo($element.children().first())
.attr({ src: plugin.settings.href, name: new Date().getTime() });
As you can see I was attempting to log the height of the iFrame but it always prints 0 (as temporary workaround I'm setting the dimensions statically)
EDIT: Another solution which I've updated this OP with returns the error:
Error: Permission denied to access property 'document' if (iframeWin.document.body) {