Current location: Hot Scripts Forums » General Web Coding » JavaScript » getting the actual widht and height of a span


getting the actual widht and height of a span

Reply
  #1 (permalink)  
Old 06-29-04, 12:47 PM
davidklonski davidklonski is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
getting the actual widht and height of a span

Hello

I have defined a span object and gave it an id.
The span contains nested tags which define its content.

Is there a way of know what are the precise dimensions of the span in pixels?
I would like to know what are the width & height that the span will occupy once it will be display on the screen.

I tried the following:
Code:
var spanObj = document.getElementByID('mySpan');
var width = spanObj.style.width;
var height = spanObj.style.height;
That however gives me the width and height values that I have set when the span was defined. If the dimensions of the span become different once it is displayed, then I don't know what the new dimensions are.

I even tried:
Code:
var spanObj = document.getElementByID('mySpan');
var width = spanObj.runtimeStyle.width;
var height = spanObj.runtimeStyle.height;
thansk in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to obtain the width & height of the client area davidklonski JavaScript 1 05-14-05 03:13 PM


All times are GMT -5. The time now is 12:40 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.