Firefox compatible iframe highly adaptive code_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:39:02
Original
1047 people have browsed it

There are a lot of highly adaptive codes for iframes on the Internet, but they are quite messy. This article organizes the following codes based on practicality:

JavaScript part:

Collapse JavaScript Code copy content to clipboard

<script type="text/javascript"> function SetCwinHeight(iframeObj){ if (document.getElementById){ if (iframeObj){ if (iframeObj.contentDocument && iframeObj.contentDocument.body.offsetHeight){ iframeObj.height = iframeObj.contentDocument.body.offsetHeight; } else if (document.frames[iframeObj.name].document && document.frames[iframeObj.name].document.body.scrollHeight){ iframeObj.height = document.frames[iframeObj.name].document.body.scrollHeight;   } } } } </script> 
Copy after login

 


html part:

Collapse XML/HTML Code copy content to clipboard

<iframe name="frameContent" src="*" frameborder="0" width="100%" onload="SetCwinHeight(this)"></iframe> 
Copy after login

 


Fill in the address of the iframe page where * is marked. It should be noted that the src address must be under the same website, otherwise a "permission prohibited" error will occur.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template