MDA/MDD/TDD/DDD/DDDDDDD
          posts - 536, comments - 111, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          iframe自適應高度

          Posted on 2010-05-04 11:00 leekiang 閱讀(416) 評論(0)  編輯  收藏 所屬分類: web開發
          192.168.108.25/AppA的a.jsp里有一個iframe為b.jsp,a和b跨域,如何讓這個iframe自適應高度?

          a.jsp
          <iframe src="http://192.168.2.97/AppB/b.jsp" id="b_iframe"? scrolling="no"? frameborder="0"></iframe>

          b.jsp
          <iframe id='c_iframe'? height='0' width='0' src='http://192.168.108.25/AppA/c.jsp' style='display:none' ></iframe>
          <script>
          var b_height = Math.max(document.body.scrollHeight,document.body.clientHeight);
          var c_iframe = document.getElementById('c_iframe');
          c_iframe.src = c_iframe.src+'#'+b_height;
          </script>

          c.jsp
          <script>
          ??? var hash_url = window.location.hash;
          ??? var hash_height = hash_url.split('#')[1]+'px';
          ??? var b_iframe = window.parent.parent.document.getElementById('b_iframe');
          ??? b_iframe.style.height = hash_height;
          </script>
          主站蜘蛛池模板: 大庆市| 建德市| 北宁市| 星座| 信丰县| 遂宁市| 福州市| 皮山县| 牙克石市| 格尔木市| 永胜县| 元阳县| 尼玛县| 习水县| 万山特区| 肇州县| 凌源市| 昌吉市| 武威市| 门源| 漾濞| 浠水县| 无锡市| 桓仁| 东方市| 南城县| 大化| 象州县| 彰化市| 郸城县| 苗栗市| 潼南县| 德惠市| 夏邑县| 河西区| 许昌县| 米林县| 西和县| 甘南县| 天台县| 淅川县|