Nonsense not to say, put on code, also be a code store of their own.
Copy Code code as follows:
var temp_iframe
var content = document.getElementById (' right '); In a DOM container with ID right, 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); Self-adaptive high
});
}
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.js, and then call in the foreground page:
------------------------------------------------------------------------
<a href= "index.html" onclick= "return append (' xxxx.html ')" class= "Li1" >
<div id= "right" ></div>
<script type= "Text/javascript" src= "Iframe.js" ></script>
------------------------------------------------------------------------
Or remove the last return false in the script, front desk:
------------------------------------------------------------------------
<a href= "javascript:append (' favorite/favorites.html ')" class= "Li1" >
<div id= "right" ></div>
<script type= "Text/javascript" src= "Iframe.js" ></script>
------------------------------------------------------------------------
*/
Hey, in which, the last set of adaptive wide-height, can actually be proposed to become a function to call.
This I did not go to do so, have to see the article friend, can be encapsulated.
Among them, there are some inconvenient, for example, every time I set up the IFRAME must be different name and ID, delete the original has not been created ...
I hope we can teach you a lot.