iframe 的onload有時不起做用

<script>html

window.onload = function (){app

     var iframeB = document.getElementById("iframepage");ide

     var iframepage = document.createElement('iframe');this

     iFrameHeight("load");url

     //document.body.appendChild(iframepage);firefox

     iframeB.appendChild(iframepage);htm

 }ip


//ifram高度自適應get

    function iFrameHeight() {iframe

        var bodyHeight = 460;

        if (/msie/.test(navigator.userAgent.toLowerCase()) || /firefox/.test(navigator.userAgent.toLowerCase())) {

            bodyHeight = window.frames["iframepage"].document.body.scrollHeight;

        }

        else {

            bodyHeight = document.getElementById("iframepage").contentWindow.document.documentElement.scrollHeight;

        }


        document.getElementById("iframepage").height = bodyHeight;

    }

</script>



html


<div id="rl">

      <iframe id="iframepage"  name="iframepage" frameBorder=0 scrolling=no onLoad="iFrameHeight()" width="280" src="<?=site_url($this->config->item("front_end_access_direction")."/cart/cart_calendar_iframe?oneday=".(empty($oneDay)?'':$oneDay))?>"></iframe>

</div>

相關文章
相關標籤/搜索