隨筆 - 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
          主站蜘蛛池模板: 凯里市| 云南省| 镇赉县| 乐至县| 关岭| 兰西县| 浙江省| 溆浦县| 苍南县| 新安县| 壶关县| 灵宝市| 买车| 通许县| 孟村| 洞头县| 始兴县| 桃园市| 芦溪县| 宣威市| 顺义区| 霞浦县| 腾冲县| 隆尧县| 左云县| 临海市| 玉山县| 横峰县| 青冈县| 汤原县| 灵寿县| 额敏县| 思茅市| 华宁县| 湘乡市| 昌乐县| 阿瓦提县| 托克逊县| 襄城县| 和平区| 济宁市|