ice world

          There is nothing too difficult if you put your heart into it.
          posts - 104, comments - 103, trackbacks - 0, articles - 0

          解決document.body.clientHeight沒給你你想要的現(xiàn)象

          Posted on 2011-04-16 02:32 IceWee 閱讀(3290) 評論(1)  編輯  收藏 所屬分類: CSS
          HTML文檔中使用了腳本控制內(nèi)容的高度,所以要用到 document.body.clientHeight,但是發(fā)現(xiàn)結(jié)果卻不是想象的那樣,請教高手得來真經(jīng),是需要設(shè)置html,body樣式。試試去掉紅色的樣式設(shè)置。腳本的功能是解決窗口進(jìn)入后最大化不能自適應(yīng)的問題。
           

          demo.html

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
          <html xmlns=" http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
          <title>Eletric Power Integrative System</title>
          <style type="text/css">
             html, body {

              width
          : 100%;
              height
          : 100%;
              margin
          : 0px;
              padding
          : 0px;
             
          }

          </style>
          <script type="text/javascript">
             
          function $(id) {
              
          return document.getElementById(id);
             }


             window.onload 
          = window.onresize = function() {
              $('cententMain').style.height 
          = (document.body.clientHeight - 100+ 'px'; 
              
          //alert($('cententMain').style.height);
             }

          </script>
          </head>
          <body>
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
             
          <tr>
              
          <td>
               
          <div id="header" style="height:75px; background:#006F68; left:0px; top:0px; width:100%; z-index:1000"></div> 
              
          </td>
             
          </tr>
             
          <tr>
              
          <td>       
               
          <div id="cententMain" style="background-color:#fff; position:absolute; left:0px; top:75px; bottom:25px; width:100%; z-index:100">
                
          <iframe id="indexFrame" name="indexFrame" src="http://www.xjgc.com" width="100%" height="100%" frameborder="1"></iframe>
               
          </div> 
              
          </td>
             
          </tr>
             
          <tr>
              
          <td>
               
          <div id="footer" style="background:#006F68; border-top:1px solid #1291a9; height:25px; position:absolute; left:0px; bottom:0px; width:100%; z-index:1000" align="center" valign="bottom">
                
          <span style="font-size:11px;color:#fff;font-family:Verdana, Arial, Helvetica, sans-serif;">&copy;2008 - 2012 Icesoft</span>
               
          </div>
              
          </td>
             
          </tr>
          </table>
          </body>
          </html>


          Feedback

          # re: 解決document.body.clientHeight沒給你你想要的現(xiàn)象[未登錄]  回復(fù)  更多評論   

          2013-09-13 16:49 by 1
          1
          主站蜘蛛池模板: 古田县| 晋州市| 彩票| 钟山县| 西平县| 平阳县| 从化市| 彭水| 池州市| 漳州市| 金山区| 阳西县| 武邑县| 多伦县| 乌兰察布市| 平凉市| 府谷县| 青神县| 峡江县| 资阳市| 台前县| 抚远县| 绍兴市| 哈巴河县| 会同县| 吉首市| 兰西县| 鹤庆县| 金山区| 辰溪县| 平山县| 临安市| 新野县| 灵台县| 出国| 郎溪县| 永胜县| 定结县| 满城县| 汤原县| 饶阳县|