码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-06-26 22:37:34      阅读:210      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!