getting <div's> height

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron Gray

    #1

    getting <div's> height

    Hi,

    How do I get the size of a <div> in JavaScript, given :-

    Note I am missing out the <html>/<body>/<script> sections here :)

    ~~~

    <div id="canvas"
    style="backgrou nd-color:#f0f0f0;p osition:relativ e;height:100%;w idth:100%;"
    onresizeend="dr awAll();"></div>

    ~~~

    var h = canvas.height;
    drawChart(h);

    ~~~

    function drawAll()
    {
    h = canvas.height;
    drawChart( h)
    }

    ~~~

    If I do an alert() to print out 'h' it is coming out as 'undefined'.

    I am probably doing something simple wrong.

    Hope you can help,

    Aaron


  • Aaron Gray

    #2
    Re: getting &lt;div's&gt ; height

    > I am probably doing something simple wrong.

    Got it 'clientHeight' not just height.

    Cheers,

    Aaron


    Comment

    • RobB

      #3
      Re: getting &lt;div's&gt ; height

      "Aaron Gray" <angray@beeb.ne t> wrote in message news:<cnjkq5$ea o$1$8302bc10@ne ws.demon.co.uk> ...[color=blue][color=green]
      > > I am probably doing something simple wrong.[/color]
      >
      > Got it 'clientHeight' not just height.
      >
      > Cheers,
      >
      > Aaron[/color]

      Not quite.

      -----> HTMLElement.off setHeight <-----

      Comment

      • Aaron Gray

        #4
        Re: getting &lt;div's&gt ; height

        >> Got it 'clientHeight' not just height.[color=blue]
        > Not quite.
        > -----> HTMLElement.off setHeight <-----[/color]

        Many Thanks,

        Aaron


        Comment

        Working...