JavaScript Firefox auto load iframe Auto-Adjust High-width example _javascript tips

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.