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

谁借莪1个温暖的怀抱¢ 2022-08-10 12:57 272阅读 0赞
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>iframe</title>
  6. <script src="js/1.3.2.js"></script>
  7. <style type="text/css">
  8. *{ padding:0; margin:0;}
  9. html,body{ width:100%; height:100%; }
  10. .menu{ width:200px; height:100%; text-align:center;}
  11. .close{ display:none;}
  12. .bar{ width:5px; background:#317EF3; cursor:pointer;}
  13. .clum{ width:5px; height:100%; background:#317EF3;}
  14. .open{ width:5px; height:100%; background:#317EF3;}
  15. </style>
  16. <script type="text/javascript">
  17. $(document).ready(function(){
  18. $(".bar").click(function(){
  19. $(this).toggleClass("open");
  20. $(".menu").toggleClass("close");
  21. });
  22. });
  23. <!--
  24. //调整 PageContent 的高度
  25. function SetCwinHeight(){
  26. var iframeid=document.getElementById("iframeid"); //iframe id
  27. if (document.getElementById){
  28. if (iframeid && !window.opera){
  29. if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight){
  30. iframeid.height = iframeid.contentDocument.body.offsetHeight;
  31. }else if(iframeid.Document && iframeid.Document.body.scrollHeight){
  32. iframeid.height = iframeid.Document.body.scrollHeight;
  33. }
  34. }
  35. }
  36. }
  37. //-->
  38. </script>
  39. </head>
  40. <body>
  41. <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%" id="table">
  42. <tr>
  43. <td class="menu">菜单</td>
  44. <td class="bar"><!--<div class="clum"></div>--></td>
  45. <td height="100%"><iframe id="iframeid" οnlοad="Javascript:SetCwinHeight()" width="100%" height="100%" frameborder="0" src="http://www.baidu.com/"></iframe></td>
  46. </tr>
  47. </table>
  48. </body>
  49. </html>

发表评论

表情:
评论列表 (有 0 条评论,272人围观)

还没有评论,来说两句吧...

相关阅读

    相关 iframe高度适应

    前提:父页面是功能选项,固定在网页上。在网页留出的空白部分,用于嵌套子页面 为了美观和用户体验,子父页面共用子页面的纵向滚动条,且子页面的内容是变化的,所以要设置iframe

    相关 iframe适应高度

    [JS][]自适应高度,其实就是设置[iframe][]的高度,使其等于内嵌网页的高度,从而看不出来滚动条和嵌套痕迹。对于用户体验和网站美观起着重要作用。 如果内容是固定的,