Javascript设置iframe高度自适应(兼容主流浏览器)

Javascript设置iframe高度自适应(兼容主流浏览器)
复制代码代码如下所示:
功能setiframeheight(下){
var;
var ua = navigator.useragent.tolowercase();
VaR的;
(S = ua.match( / MSIE({ D. } +)/))sys.ie =的{ 1 }:
(S = ua.match( / / Firefox({ D. } +)/))sys.firefox =的{ 1 }:
(S = ua.match( / /铬({ D. } +)/))sys.chrome =的{ 1 }:
(S = ua.match( /歌剧。({ D. } +)/))sys.opera =的{ 1 }:
(S = ua.match( / /版本({ D. } +)* Safari /))sys.safari =的{ 1 }:0;
风险率= null;
如果(文件。getElementById){
document.getelementbyid率=(下);
{人}
eval('ptar =+下+ ';');
}
ptar.style.display =块;
如果(sys){
如果(sys.ie = = '9.0){
ptar.height = ptar.contentwindow.document.body.offsetheight + 15 +PX;
ptar.width = ptar.contentwindow.document.body.scrollwidth +PX;
否则如果}(sys.ie = = '8.0){
调试器;
ptar.height = ptar.document.body.offsetheight + 15 +PX;
ptar.width = ptar.document.body.scrollwidth +PX;
{人}
ptar.height = ptar.document.body.scrollheight + 25 +PX;
ptar.width = ptar.document.body.scrollwidth +PX;
}
}
如果(sys)
ptar.height = ptar.contentdocument.body.offsetheight + 15 +PX;
ptar.width = ptar.contentdocument.body.scrollwidth +PX;
}
如果(sys)
ptar.height = ptar.contentdocument.body.offsetheight;
ptar.width = ptar.contentdocument.body.scrollwidth;
}
如果(sys){
ptar.height = ptar.contentdocument.body.offsetheight;
ptar.width = ptar.contentdocument.body.scrollwidth;
}
如果(sys){
如果(率。contentdocument。身体。offsetheight '186){
ptar.height = ptar.contentdocument.body.offsetheight + 10;
{人}
ptar.height = ptar.contentdocument.body.offsetheight;
}
ptar.width = ptar.contentdocument.body.scrollwidth;
}
}
免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部