Resizing an IFrame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • H.A.P

    #1

    Resizing an IFrame

    hi

    I'm trying to change the size of an iframe. In the following page, how
    should I do it?

    <html>

    <head>
    <script language="javas cript">
    function resize_frm() {
    I1.width=400;
    }
    </script>
    </head>

    <body>
    <p onclick="resize _frm()">RESIZE</p>

    <iframe name="I1" src="contents.h tm" width="200" height="150">
    Your browser does not support inline frames or is currently configured not
    to display inline frames.</iframe>

    </body>

    </html>


  • Vjekoslav Begovic

    #2
    Re: Resizing an IFrame

    "H.A.P" <hapah@hotmail. com> wrote in message
    news:bkbfl2$rhm n8$1@ID-51430.news.uni-berlin.de...[color=blue]
    > hi
    >
    > I'm trying to change the size of an iframe. In the following page, how
    > should I do it?
    >
    > <html>
    >
    > <head>
    > <script language="javas cript">
    > function resize_frm() {
    > I1.width=400;
    > }
    > </script>
    > </head>
    >
    > <body>
    > <p onclick="resize _frm()">RESIZE</p>
    >
    > <iframe name="I1" src="contents.h tm" width="200" height="150">
    > Your browser does not support inline frames or is currently configured not
    > to display inline frames.</iframe>
    >
    > </body>
    >
    > </html>[/color]

    If you have an inline frame with id:

    <iframe id="I1" src="contents.h tm" width="200" height="150">

    than you could write:

    document.getEle mentById("I1"). width = 400





    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Resizing an IFrame

      "H.A.P" <hapah@hotmail. com> writes:
      [color=blue]
      > I'm trying to change the size of an iframe. In the following page, how
      > should I do it?[/color]
      [color=blue]
      > <script language="javas cript"[/color]
      The type attribute is required, and language is deprecated:
      <script type="text/javascript">
      [color=blue]
      > function resize_frm() {
      > I1.width=400;[/color]

      You shouldn't access named elements as properties of the global object.
      Few browsers allow that (although one of them is used quite a lot).

      Either
      var iframe = document.getEle mentsByTagName( "iframe")[0];
      or give the iframe an id and use document.getEle mentById.

      To change the width, use style.width:
      iframe.style.wi dth = "400px";
      Remember the unit, it is required in CSS.
      [color=blue]
      > <iframe name="I1" src="contents.h tm" width="200" height="150">[/color]

      Don't use the width and height attributes, but use CSS instead:
      <iframe name="I1" id="iframe1Id" src="contents.h tm"
      style="width:20 0px;height:150p x;">

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      Working...