分享

iframe跨域自适应

 star_xiong 2012-07-14


//*main*//
<script type="text/javascript">
function init(){
   document.domain = 'www.';
   var iframeTag = document.getElementById('frameB'),iframeSrc = 'http://www./?newspapers-hylist';  
   iframeTag.src = iframeSrc;
   iframeTag.style.display = 'block';
};
 
function callback(h){
   var iframeB = document.getElementById('frameB');
    iframeB.style.height= h + 'px';
    iframeB.src += '#'+ h
};
</script>
<iframe name="news" id="frameB" src="http://www./?newspapers-hylist" width="980" height="800" scrolling="auto" frameborder="0" marginheight="0" marginwidth="0"></iframe>
//*main end*//

//*iframepagec.htm
<script type="text/javascript">
    document.domain = 'www.';
    top.callback(window.location.href.split('#')[1]);
</script>

*//
//*页面B
<iframe id="frameC" style="height:0px;width:0px;display:none;"></iframe>
<script type="text/javascript">
 function init(){
   var iframeTag = document.getElementById('frameC'),iframeSrc = 'http://www./about/iframePageC.html#',pageHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
   iframeTag.src = iframeSrc + pageHeight;
   iframeTag.style.display = 'block';
 };
</script>
*//

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多