View Full Version : more 20 pixels width?

10-16-2005, 11:39 PM
I'am newbie to javascript.
there is a simple question that,
any reasons a web page is width more 20
I written a simple code that loop throught the
element to calc the distance from left page to
target element. when its run, it show me
2 more span tag with each 10 pixels width.
is that normal or not?

thank you


10-17-2005, 08:07 AM
Without seeing your code it could be a number of things but you say width, well it could be the scrollbar taking up those 20px but then you say it picks up two more spans? Show us your code.

10-17-2005, 01:48 PM
thanks _Aerospace_Eng_
the code listed,

<!-- html code -->
<div id="level1" style="position:absolute;left:100;top:100;width;200;
<div id="level2" style="position:absolute;left:100;top:100;width;100;
<input type="button" value="Check it"
onclick="return checkwidth(document.all.level2);" />

// script code
function checkwidth(link) {
if(!link) {
window.status = "parameters null";

var obj = new Object();
obj.x = link.offsetLeft;
obj.y = link.offsetTop;
obj.width = link.style.posWidth;
obj.height = link.style.posHeight;

var parentEl = link.parentElement;
while(parentEl) {
var lastParent = parentEl;
alert(parentEl.tagName + " / " + parentEl.offsetLeft);
obj.x += parseInt(parentEl.offsetLeft);
obj.y += parseInt(parentEl.offsetTop);
parentEl = parentEl.parentElement;
window.status = lastParent.tagName;
return false;

coz I'am newbie, many things dont know. if I'am wrong, please point out that.
thanks a lot