首页 > 其他 > 详细

iframe 子页面获取父页面的元素并且控制样式

时间:2016-06-26 22:35:28      阅读:501      评论:0      收藏:0      [点我收藏+]

父页面的代码

                      <div id="div5" style="position:relative;height:500px;">
                       <iframe scrolling="auto" frameborder="0"  id="content" name="content" src ="./cpcia_gonggao.jsp"
                        bordor="0" style="width:800px;height:500px;">
                       </iframe>
                       </div>  

 

子页面的JS代码

 

<script>
$(function(){
    var p_window = window.top;
    alert($(p_window).height());
    var p_demo = window.top.document.getElementById(‘content‘);
    var val=window.top.document.getElementById(‘div5‘);
    alert($(p_demo).height()); 
    p_demo.style.height="1300px";
    val.style.height="1300px";
})
</script>

 

iframe 子页面获取父页面的元素并且控制样式

原文:http://www.cnblogs.com/275147378abc/p/5618662.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!