Home >Web Front-end >HTML Tutorial >Firefox compatible iframe highly adaptive code_html/css_WEB-ITnose

Firefox compatible iframe highly adaptive code_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:39:021084browse

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> 

 


html part:

Collapse XML/HTML Code copy content to clipboard

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

 


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.

Statement:
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