Not much nonsense, paste Code It is also a code storage.
Copy code The Code is as follows: var temp_iframe
VaR content = Document. getelementbyid ('right'); // create an IFRAME and adaptive width/height in the right Dom container.
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", please specify frames=the_iframe=.doc ument. Body. scrollwidth); // adaptive width
Temp_iframe.setattribute ("height", please specify frames=the_iframe=.doc ument. Body. scrollheight); // adaptive height
});
}
Else
{
Temp_iframe.addeventlistener ('load', function ()
{
Temp_iframe.setattribute ("width", please specify frames=the_iframe=.doc ument. Body. scrollwidth );
Temp_iframe.setattribute ("height", please specify frames=the_iframe=.doc ument. Body. scrollheight );
}, False );
}
C ++;
Return false;
}
/* Call Method
Save the script as a script file: IFRAME. JS, and then call it on the front-end 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 final return false in the script. Foreground:
------------------------------------------------------------------------
<A href = "javascript: append ('favorite/favorites.html ')" class = "Li1">
<Div id = "right"> </div>
<SCRIPT type = "text/JavaScript" src = "iframe. js"> </SCRIPT>
------------------------------------------------------------------------
*/
Hey, in this case, the final setting of adaptive width and height can actually be proposed to be called as a function.
I did not do this.ArticleCan be encapsulated by yourself.
There are also some inconvenient ones. For example, each time I create an IFRAME, different names and IDs are required, and it is not possible to delete the previously created ones in real time ......
I hope you can give me more advice.