隨筆 - 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
          主站蜘蛛池模板: 平果县| 万年县| 宁津县| 高邮市| 延长县| 称多县| 松江区| 泗阳县| 定陶县| 洪泽县| 托里县| 高陵县| 都匀市| 孟州市| 禹城市| 东丰县| 礼泉县| 扬中市| 定兴县| 江油市| 安平县| 封丘县| 伊宁市| 双辽市| 临沧市| 鄯善县| 黄山市| 大埔县| 延川县| 南华县| 明星| 永春县| 荆门市| 石门县| 平果县| 南丰县| 屏南县| 五大连池市| 龙州县| 大方县| 神农架林区|