getting <div's> height

A

Aaron Gray

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="background-color:#f0f0f0;position:relative;height:100%;width:100%;"
onresizeend="drawAll();"></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
 
A

Aaron Gray

I am probably doing something simple wrong.

Got it 'clientHeight' not just height.

Cheers,

Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top