JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old June 10th, 2006, 12:10 PM
wexen wexen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 2 wexen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 41 sec
Reputation Power: 0
Getting size of auto sized DIV

Hello !

If a div has the CSS :

div {width : auto;}

And i do something like this :

alert(mydiv.currentStyle.width);

it returns :

"auto"

What i really want is the actual pixel value ...

Any ideas ?

Reply With Quote
  #2  
Old June 11th, 2006, 12:00 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 540 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 1 h 44 m 31 sec
Reputation Power: 3
width

Hi wexen, welcome to the forums,
Try to get it's "offsetWidth"

Reply With Quote
  #3  
Old June 12th, 2006, 02:39 AM
wexen wexen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 2 wexen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 41 sec
Reputation Power: 0
Thumbs up Great stuff !!

That did the trick thank you !

I now have somthing like this :

// First loop do some stuff and get the width of the biggest div in the array
for(var no=0;no<draggableItems.length;no++){
draggableItems[no].onmousedown = startDrag;
draggableItems[no].style.cursor = 'hand';
if(itemWidth < draggableItems[no].offsetWidth) {itemWidth = draggableItems[no].offsetWidth}

}
// Second loop set all div .style.width attribute to itemWidth
for(var no=0;no<draggableItems.length;no++){
draggableItems[no].style.width = itemWidth;

}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Getting size of auto sized DIV


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway