The Irish Penguin Watching Open Source unfold across Ireland

5May/070

Javascript Tip Of The Day: “When Is A Width Not A Width?”

This is a bit of a gotcha for young players in the Javascript game. You have a web page with a DIV which you fill dynamically with, let's say, 5 IMG elements. How do you get the width of the DIV? You can try "document.getElementById('divId').width" but it will do you no good. The answer: use "document.getElementById('divId').offsetWidth". Here's a handy guide when it comes to DHTML element position and locations.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.