2013-04-23 48 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,*'); 
    });