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 閱讀(1288) | 評論 (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 閱讀(317) | 評論 (0)編輯 收藏

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

          導航

          統計

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          收藏夾

          JAVA學習網站

          綜合

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 云安县| 长海县| 连云港市| 绥江县| 平南县| 应用必备| 海宁市| 越西县| 六盘水市| 高雄县| 渝中区| 西林县| 株洲县| 濮阳市| 寿阳县| 白银市| 漳浦县| 营口市| 钦州市| 富锦市| 五家渠市| 石屏县| 手游| 张家界市| 军事| 宜兴市| 安福县| 木里| 淮北市| 新密市| 盐津县| 大同县| 庄浪县| 新干县| 安新县| 昆山市| 民权县| 武城县| 阳江市| 邵阳市| 崇明县|