iframe automatically obtain onload width
Copy Code code as follows:
function AutoResize (IFRAME)
{
Firefox
if (Iframe.contentwindow)
{
Iframe.height = Iframe.contentWindow.document.documentElement.scrollHeight;
Iframe.width = Iframe.contentWindow.document.documentElement.scrollWidth;
}
Ie
else if (iframe.contentdocument) {
Iframe.height = Iframe.contentDocument.width;
Iframe.width = Iframe.contentDocument.height;
}
}
IFRAME Auto Load:
Copy Code code as follows:
var tdobj = document.getElementById (' IFRTD ');
tdobj.innerhtml = ' QQ dynamic loading ... ';
var iframe = document.createelement ("iframe");
IFRAME.SRC = ' http://www.zbphp.com/';
if (iframe.attachevent) {
Iframe.attachevent ("onload", Autoresize.call (IFRAME)); #报错
Iframe.attachevent ("onload", function () {
AutoResize (IFRAME);
});
} else {
Iframe.onload = Autoresize.call (iframe); #报错不支持
Iframe.onload = function () {
AutoResize (IFRAME);
};
}
tdobj.innerhtml = ';
Tdobj.appendchild (IFRAME);
In fact, the iframe.onload here want to write iframe.onload = Autoresize.call (iframe); Unfortunately, the error is not supported.
I never know how JavaScript makes a function call. For example, when you encounter iframe.onload = function () {} Calling functions with parameters, such cases can only be written in this way, not as direct as other programs.
I've seen the Apply () call () before, but I don't support it. Why?