Compatible with mainstream browsers for IFRAME adaptive height JS scripting _javascript Tips

Source: Internet
Author: User
Compatible with the mainstream browser's Iframe adaptive height, the JS script is as follows:
Copy Code code as follows:

IFRAME highly adaptive
function Iframeautofit (iframeobj) {
settimeout (function () {
if (!iframeobj) return;
Iframeobj.height = (iframeobj.document iframeObj.Document.body.scrollHeight: IframeObj.contentDocument.body.offsetHeight);
}, 200);
}<span style= "font-family:arial, Helvetica, Sans-serif;" > </span>

Call Method:
Copy Code code as follows:

<iframe id= "Hqright" name= "Hqright" onload= "Javascript:iframeautofit" (this); "
Height= "235px;" width= "770px" frameborder= "0" scrolling= "no"
Src= "Market/hqdata_page.aspx?t=tjs" ></iframe>

Extended:
Copy Code code as follows:

Add styles Dynamically
function addsheetfile (obj, path) {
if (obj = = Undefined | | obj = NULL)
obj = document;

var fileref = obj.createelement ("link")
Fileref.rel = "stylesheet";
Fileref.type = "Text/css";
Fileref.href = path;
Fileref.media = "screen";
var headobj = obj.getelementsbytagname (' head ') [0];
Headobj.appendchild (FILEREF);
}

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.