开发者

Javascript: How to resize frame?

How to, using JavaScript, resize frame inside frameset?

I've found jQuery slideUp (http://api.jquery.com/slideUp/) function very useful, however it's not possible to implement it to work w开发者_JS百科ith the frame.


To resize a frame, you'll have to change the rows/cols -attribute of the parent frameset-element.

Short example:

<html>
<head>
<script>
window.onload=function()
{
  var frame=window.frames[0];
      frame.document.open();
      frame.document.write('<input  type="button" \
                                    onclick="parent.fx()" \
                                    value="resize this frame to 150px height">');
      frame.document.close();
}
var i=50;
function fx()
{

  timer=setInterval(
                    function()
                    {
                      if(i>150)
                            {
                              clearTimeout(timer);
                            }
                      else  {
                              document.getElementsByTagName('frameset')[0]
                              .setAttribute('rows',(i++)+',*');
                            }
                    }
                    ,20)
}
</script>
</head>
<frameset rows="50,*">
  <frame src="about:blank"/>
  <frame src="about:blank"/>
</frameset>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜