隨筆 - 154  文章 - 60  trackbacks - 0
          <2007年10月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          聲明:

          該blog是為了收集資料,認識朋友,學習、提高技術,所以本blog的內容除非聲明,否則一律為轉載!!

          感謝那些公開自己技術成果的高人們!!!

          支持開源,尊重他人的勞動!!

          常用鏈接

          留言簿(3)

          隨筆分類(148)

          隨筆檔案(143)

          收藏夾(2)

          其他

          學習(技術)

          觀察思考(非技術)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          main.htm:

          <html> 
              <head> 
                 <meta  http-equiv='Content-Type'  content='text/html;  charset=gb2312'> 
                 <meta  name='author'  content='F.R.Huang(meizz梅花雪)//www.meizz.com'> 
                 <title>iframe自適應加載的頁面高度</title> 
              </head> 
              
              <body>
                  <iframe src="child.htm"></iframe>
              </body>
          </html>

          child.htm:

          <html> 
          <head> 
             <meta  http-equiv='Content-Type'  content='text/html;  charset=gb2312'> 
             <meta  name='author'  content='F.R.Huang(meizz梅花雪)//www.meizz.com'> 
             <title>iframe  自適應其加載的網頁(多瀏覽器兼容)</title> 
             <script  language=javascript>
             function iframeAutoFit()
             {
                try
                {
                   if(window!=parent)
                   {
                    var a = parent.document.getElementsByTagName("IFRAME");
                      for(var i=0; i<a.length; i++) //author:meizz
                      {
                         if(a[i].contentWindow==window)
                         {
                             var h = document.body.scrollHeight;
                             if(document.all) {h += 4;}
                             if(window.opera) {h += 1;}
                             a[i].style.height = h;
                         }
                      }
                   }
                }
                catch (ex)
                {
                   alert("腳本無法跨域操作!");
                }
             }
             if(document.attachEvent)  window.attachEvent("onload",  iframeAutoFit); 
             else  window.addEventListener('load',  iframeAutoFit,  false); 
             </script> 
          </head> 
          <body> 
             <div  style="width:  200;  height:  400;  background-color:  yellow"> 
                 iframe  自適應其加載的網頁(多瀏覽器兼容) 
             </div> 
          </body> 
          </html>

          posted on 2007-10-09 09:39 lk 閱讀(205) 評論(0)  編輯  收藏 所屬分類: ajax&js
          主站蜘蛛池模板: 东兰县| 张家界市| 军事| 安吉县| 油尖旺区| 武冈市| 乌兰县| 贵德县| 贺州市| 宣恩县| 岱山县| 于都县| 平安县| 五河县| 云龙县| 天长市| 乐至县| 手游| 泗水县| 左贡县| 武平县| 石首市| 调兵山市| 息烽县| 榆中县| 忻州市| 金山区| 永康市| 辽阳市| 顺平县| 龙井市| 象山县| 枞阳县| 衡水市| 航空| 碌曲县| 通江县| 大冶市| 盘山县| 渭南市| 崇义县|