Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 with the frame.

like image 237
Paul Avatar asked Dec 16 '10 00:12

Paul


People also ask

How do I resize a frame in HTML?

The noresize attribute specifies that a <frame> element cannot be resized by the user. By default, each <frame> in a <frameset> can be resized by dragging the border between the frames.

Which attribute prevents a frame from resizing?

The noresize attribute specifies that a frame cannot be resized by the user.

What is the frame in JavaScript?

Frames are a special case in JavaScript — each frame behaving like the separate document that it is. This means that to modify anything in another frame, you first need to gain control of this frame by working with something called the frame tree.

What is the function of no resize attribute of frame tag in HTML?

The HTML <frame> noresize attribute is used to specify that the frame element can not be resize by the user. This type of attribute is used to lock the size of the frame element. Attribute Values: noresize: It defines the frame element that can not be resize by the user.


1 Answers

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>
like image 153
Dr.Molle Avatar answered Sep 24 '22 14:09

Dr.Molle