Recently, the highly adaptive problem of iframe was solved. I searched a lot of solutions on the internet, and I tried these solutions one by one. Finally, I found that they didn't work in my projects, later, I found that my webpage was accessed through file. I put the webpage code under apache and accessed it through http. When loading iframe, I called the following js method:
Copy codeThe Code is 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, the webpage is highly adaptive (for other solutions, I did not pay attention to trying it out), but when I access the webpage through file, the same code log always reports: unsafew.criptattempttoaccessframewithurlfile: /// E:/workspace/html5/exam.html from
FramewithURLfile: // E:/workspace/html5/quiz_preview.html.
Domains, protocolsandportsmustmatch.
This error is reported in each solution. It can only be solved from this problem. Later, it was found that this cross-origin access through file method chrome is not allowed by default, check how to set chrome to allow cross-origin access: the simplest method is to right-click the chrome icon and add '-- disable-web-security' to the property-> target'
Restart chrome to open the page to be called. The problem is fixed.