您的位置:首页 > Web前端 > JQuery

jquery iframe自适应高度代码(浏览器兼容)

2013-06-08 11:50 651 查看
这里提供一款由jquery提供iframe自适应高度代码并且是兼容多浏览器iframe自适应高度。

更多详细内容请查看:http://www.111cn.net/wy/jquery/jquery_iframe.htm

$("#ipersonalinfo").load(function() {

$(this).height($(this).contents().height());

})

iframe 自适应高度

<script type=”text/网页特效”>

//iframe 自适应高度

function setcwinheight(){

var bobo=document.getelementbyid(”main”); //iframe id

if (document.getelementbyid){

if (bobo && !window.opera){

if (bobo.contentdocument && bobo.contentdocument.body.offsetheight){

bobo.height = bobo.contentdocument.body.offsetheight;

}else if(bobo.document && bobo.document.body.scrollheight){

bobo.height = bobo.document.body.scrollheight+30;

//alert(document.getelementbyid(”amdright”).style.width);

}

}

}

}

</script>

<iframe id=”main” name=”main” src=”main.php教程” scrolling=”no” width=”100%” frameborder=”0′ onload=”setcwinheight()”></iframe>

方法二

<script type="text/javascript">

function resizecontent()

{

$(window.parent.document).find("#if1").height($("#content").height());

}

function show400()

{

if($("#test400").css教程("display") == "none")

{

$("#test400").css("display","");

resizecontent();

}

else

{

$("#test400").css("display","none");

resizecontent();

}

}

$(document).ready(function(){

resizecontent();

})

</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: