The powerful function of the IFRAME is not much to say, it is not only used by developers often, and hackers often use it, in short, the people know its powerful, but the IFRAME has a fatal "BUG" is the height of the IFRAME can not automatically adapt, which makes many people have a headache. Baidu or Google, a lot of solutions, but try, you will find a lot of problems: Poor browser compatibility , not adaptive , only support the same domain IFRAME and many other issues, especially the cross-domain iframe Highly adaptive problem. There is no way to find a viable solution on the web (the only one that mentions joining the proxy page has been tested and found useless). Isn't there really a workable solution? No, below the Xiao Ming son and everyone to share a powerful method, the code is as follows:
<style>
body {Margin-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;overflow:hidden;}
</style>
<body>
<iframe src=\ ' #\ ' "//hi.baidu.com/' width=" 100% ' height= ' 100% ' frameborder= ' 0 ' name= "_blank" id= "_blank" ></ Iframe>
</body>
The code is powerful:
1. This method is perfectly compatible with ie6,7,8, fire Fox,chrome,opera and other mainstream browsers;
2. Same domain, cross-domain support;
3. Do not call any JS script;
Note three points.
1. The beginning of the file cannot be:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Must be
2. Overflow:hidden in body style; Absolutely not omitted;
height= ' 100% ' in 3.Iframe and scroll bar cannot be set to No (default is yes, not set)
All right, try it now. 100% won't let you down.
CSS perfect for iframe height adaptation (cross-domain support)