Home > Web Front-end > JS Tutorial > iframe adaptive height js script compatible with mainstream browsers_javascript skills

iframe adaptive height js script compatible with mainstream browsers_javascript skills

WBOY
Release: 2016-05-16 17:04:32
Original
1090 people have browsed it

Compatible with the Iframe adaptive height of mainstream browsers, the js script is as follows:

Copy code The code is as follows:

//iframe height adaptive
function iframeAutoFit(iframeObj) {
setTimeout(function () {
if (!iframeObj) return;
iframeObj.height = (iframeObj.Document ? iframeObj. Document.body.scrollHeight : iframeObj.contentDocument.body.offsetHeight);
}, 200);
} < /span>

Call method:
Copy code The code is as follows:



Extension:
Copy the code The code is as follows:

//Dynamicly add styles
function addSheetFile(obj, path) {
if (obj == undefined || obj == null)
obj = document;

var fileref = obj.createElement("link")
fileref.rel = "stylesheet";
fileref.type = "text/ css";
fileref.href = path;
fileref.media = "screen";
var headobj = obj.getElementsByTagName('head')[0];
headobj.appendChild(fileref) ;
}
Related labels:
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