Without further ado, pasting the code can be regarded as your own code storage.
var temp_iframe
var content = document.getElementById( 'right'); //In the DOM container with the id of right, create iframe and adapt width and height
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.js, and then call it on the front page:
------------ -------------------------------------------------- ----------
--------- -------------------------------------------------- -------------
Or remove the last return false in the script, frontend:
----------------------------- -------------------------------------------------- --
--------------------- -------------------------------------------------- -
*/
Hey, the final setting of adaptive width and height can actually be made into a function to call.
I didn’t do that. Friends who have seen the article can package it themselves.
Among them, there are still some inconveniences. For example, the iframe I create must have a different name and ID every time, and it is not possible to delete the original one immediately...
I still hope you can give me some advice.