2013-04-23 51 views
1

有一个框架:我如何帧的高度从另一个帧改变框架使用JavaScript

<frameset rows="30px,*"> 
    <frame id="frame1" src="frame1source.html"> 
    <frame id="frame2" src="frame2source.html"> 
</frameset> 

我需要能够从#帧1中使用jQuery更改#帧2的高度。

我试过很多解决方案都无济于事,包括:

$(window.parent.frames[0].document).css("height",300); 

回答

0

$( “#帧2”),CSS( “高度”,300); 这适合你吗?

+0

不,这没有奏效。 – lilbiscuit 2013-04-23 22:42:22

+0

我正在使用[此解决方案](http://stackoverflow.com/questions/11381576/animating-frame-resizing)。但这也起作用:'parent.document.getElementsByTagName('frameset')[0] .rows =“300,*”;' – lilbiscuit 2013-04-24 00:07:53

2

好吧我解决了这个问题,使用纯JS通过调整框架集,而不仅仅是一个框架。

parent.document.getElementsByTagName('frameset')[ 0 ].rows="300,*"; 
0

您可以使用以下标签:

$("#fromdate, #todate").click(function() { 
     $('frameset', top.document).eq(2).attr('rows', '300,*'); 
    });