2009年2月26日

          iframe高度自動調整(通過IE,firefox,opera測試)

          1.index.html
              <iframe id="mainIframe" scrolling="no" frameborder="0" width="100%" src="a.html"></iframe>
              <a href="#" onclick="page('a.html')">a頁面</a><a href="#" onclick="page('b.html')">b頁面</a>

          2 a.html  //內嵌頁面
              <script language="javascript">
                    changeHight();
              </script>

          3. b.html  //內嵌頁面
               <script language="javascript">
                    changeHight();
              </script>

          4. page.js
           function changeHight(){
            var iFrm = parent.document.getElementById("mainIframe");
               var subWeb = iFrm.contentDocument;
               if(subWeb){
              if (subWeb.body.scrollHeight>480)
             iFrm.height = subWeb.body.scrollHeight+20;
            else
                iFrm.height=500;
            } 
            if(top.document.frames["mainIframe"].document && window.document.body.scrollHeight!="0"){
             parent.document.getElementById("mainIframe").style.height=window.document.body.scrollHeight;
            }
            if(top.document.frames["mainIframe"].document && window.document.body.scrollHeight=="0"){
             parent.document.getElementById("mainIframe").style.height=500;
            }
          }

          function page(page){
              document.getElementById("mainIframe").src=page;
          }



          造成IE,FireFox,Opera中Iframe顯示差異原因在于
          1.iframe在FireFox中取法為parent.document.getElementById("mainIframe").contentDocument,而在ie,opera中為parent.document.getElementById("mainIframe").document
          2.當頁面無滾動時,window.document.body.scrollHeight在IE中能取到,fireFox和Opera中取不到。

          posted @ 2009-04-21 14:05 software5168 閱讀(1292) | 評論 (0)編輯 收藏

          文件上傳下載

               摘要: 1.myapp/index.html <html> <head> 文件操作 <iframe id="iframefile" scrolling="no" frameborder="0" width="100%" src="/myapp/fileUpload.jsp"></iframe> &l...  閱讀全文

          posted @ 2009-02-26 17:11 software5168 閱讀(322) | 評論 (0)編輯 收藏

          <2009年2月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          1234567

          導航

          統計

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          收藏夾

          JAVA學習網站

          綜合

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 临猗县| 宁武县| 石景山区| 永寿县| 鞍山市| 杂多县| 盐亭县| 大同市| 荥阳市| 佛坪县| 榆社县| 肇源县| 孝感市| 瑞丽市| 麦盖提县| 辛集市| 泰州市| 枞阳县| 永州市| 乃东县| 云安县| 保康县| 龙海市| 凌海市| 白沙| 景洪市| 临泉县| 锡林浩特市| 綦江县| 获嘉县| 敖汉旗| 岚皋县| 湖州市| 永寿县| 汶上县| 陇南市| 肇源县| 永修县| 墨竹工卡县| 介休市| 德州市|