Recently to achieve an IFRAME highly adaptive this problem, a lot of online search solutions, and summed up on those several, I try these programs, and finally found that in my project did not work, and later found that they do the Web page is accessed by file way, Put the web page code under Apache access through the HTTP protocol, when the IFRAME load call the following JS method:
Copy Code code as follows:
<spanstyle= "font-family:kaiti_gb2312; font-size:18px ">functionsetwinheight (obj)
{
Varwin=obj;
if (document.getElementById)
{
if (Win&&!window.opera)
{
if (win.contentdocument&&win.contentdocument.body.offsetheight)
Win.height=win.contentdocument.body.offsetheight;
ElseIf (win. Document&&win. Document.body.scrollHeight)
Win.height=win. Document.body.scrollHeight;
}
}
}</span>
Sure enough, page height can be adaptive (for other programs should also have effect, I did not pay attention to try), and file access to the Web page the same code log always reported: Unsafejavascriptattempttoaccessframewithurlfile :///e:/workspace/html5/exam.htmlfrom
Framewithurlfile:///e:/workspace/html5/quiz_preview.html.
Domains,protocolsandportsmustmatch.
Every solution tries to report the wrong is this, can only be solved from this problem, and later found that this way through file Cross-domain access is not allowed by default, and how to set the Chrome allow Cross-domain access: The simplest way in the Chrome icon right button, attribute-> After the target is added '--disable-web-security '
Restart Chrome to open the page you want to tune, the problem is solved