IFrame Adaptive width, height IE6 7 8,firefox 3.86

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax content create document firefox function high html

Var temp_iframe
var content = document.getElementById (' right ');//id for Right's DOM container, create IFRAME and wide-high adaptive
var c = 0;
function append (filename)
{
var the_iframe = "HelpFile" + C;
Temp_iframe = document.createelement ("iframe");
temp_iframe.src = filename;
Temp_iframe.scrolling = "no";
Temp_iframe.setattribute ("frameborder", "0");
Temp_iframe.id = the_iframe;
Temp_iframe.name = the_iframe;
Scroll (0, 0);
content.innerhtml = "";
Content.appendchild (temp_iframe);
if (document.all)
{
Temp_iframe.attachevent (' onload ', function ()
{
Temp_iframe.setattribute () Width ", window.frames[the_iframe].document.body.scrollwidth); Adaptive width
Temp_iframe.setattribute ("height", window.frames[the_iframe].document.body.scrollheight);//Adaptive Height
}) ;
}
Else
{
Temp_iframe.addeventlistener (' Load ', function ()
{
Temp_iframe.setattribute ("width") Window.frames[the_iframe].document.body.scrollwidth);
Temp_iframe.setattribute ("height", window.frames[the_iframe].document.body.scrollheight);
}, False);
}
C + +;
return false;
}
/* Call method
Save this script as a script file: IFrame. Web effects, and then call on the foreground page:
---------------------------------------------------- --------------------

<a href= "index.html" onclick= "return append (' xxxx.html ')" class= "Li1" >
<div id= "right" ></div>
<script type= "text/web Effects" src= "iframe". Web Effects ></script>
------------------------------------------------------------------------
Or remove the last return false in the script, front desk:
------------------------------------------------------------------------

<a href= "Web effects: Append (' favorite/favorites.html ')" class= "Li1" >
<div id= "right" ></div>
<script type= "Text/javascript" src= "Iframe.js" ></script>

Related Article

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.