iframe高度宽度自适应兼容所有浏览器

来源:互联网 发布:重庆市数字图书馆软件 编辑:程序博客网 时间:2024/05/03 15:53
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>iframe</title><script src="js/1.3.2.js"></script><style type="text/css">*{ padding:0; margin:0;}html,body{ width:100%; height:100%; }.menu{ width:200px; height:100%; text-align:center;}.close{ display:none;}.bar{ width:5px; background:#317EF3; cursor:pointer;}.clum{ width:5px; height:100%; background:#317EF3;}.open{ width:5px; height:100%; background:#317EF3;}</style><script type="text/javascript">$(document).ready(function(){  $(".bar").click(function(){    $(this).toggleClass("open"); $(".menu").toggleClass("close");  });});<!--  //调整 PageContent 的高度   function SetCwinHeight(){  var iframeid=document.getElementById("iframeid"); //iframe id  if (document.getElementById){   if (iframeid && !window.opera){    if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight){     iframeid.height = iframeid.contentDocument.body.offsetHeight;    }else if(iframeid.Document && iframeid.Document.body.scrollHeight){     iframeid.height = iframeid.Document.body.scrollHeight;    }   }  } }//-->   </script></head><body><table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%" id="table">  <tr>    <td class="menu">菜单</td>    <td class="bar"><!--<div class="clum"></div>--></td>    <td height="100%"><iframe id="iframeid" onload="Javascript:SetCwinHeight()" width="100%" height="100%" frameborder="0" src="http://www.baidu.com/"></iframe></td>  </tr></table></body></html>

0 0
原创粉丝点击