Iframe automatically obtains the onload height and width
Copy codeThe Code is as follows:
Function AutoResize (iframe)
{
// Firefox
If (iframe. contentWindow)
{
Iframe. height = iframe.content?document.doc umentElement. scrollHeight;
Iframe. width = iframe.content?document.doc umentElement. scrollWidth;
}
// IE
Else if (iframe. contentDocument ){
Iframe. height = iframe. contentDocument. width;
Iframe. width = iframe. contentDocument. height;
}
}
Iframe automatic loading:
Copy codeThe Code is 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); # error
Iframe. attachEvent ("onload", function (){
AutoResize (iframe );
});
} Else {
// Iframe. onload = AutoResize. call (iframe); # the error message is not supported.
Iframe. onload = function (){
AutoResize (iframe );
};
}
TdObj. innerHTML = '';
TdObj. appendChild (iframe );
In fact, the iframe. onload here is intended to be written as iframe. onload = AutoResize. call (iframe); unfortunately, an error is returned, not supported.
I have never known how javascript calls functions. For example, when iframe. onload = function () {} calls a function and has parameters, such a case can only be written in this way, rather than directly passing parameters like other programs.
I have seen apply () call () before, but none of them are supported. Why?