...

View Full Version : more 20 pixels width?



bigtiger
10-16-2005, 10:39 PM
hi,
I'am newbie to javascript.
there is a simple question that,
any reasons a web page is width more 20
pixels.
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

Eric,

_Aerospace_Eng_
10-17-2005, 07: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.

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

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

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum