PDA

View Full Version : Get offset



guymclaren
12-08-2004, 06:53 AM
Can some one explain this to me and also how I could modify the positioning based on this or a variant thereof please.

I need to know what this is doing line by line and how to move the drop down say 65 pixels left and 85 pixels up. This is from the Drop down menu script.

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

guymclaren
12-09-2004, 06:59 AM
a forum if no one answers any questions?

cr3ative
12-09-2004, 10:28 AM
Which script are you using? Please provide a link.

cr3ative

guymclaren
12-10-2004, 11:21 AM
http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

cr3ative
12-10-2004, 12:51 PM
Find these 2 lines:


dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"

And change them to this:
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+50+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+50+obj.offsetHeight+"px"

Which will add 50 to the position from left and 50 top position from top. To make it 65px to the left and 85px up as you suggested, you could do this:

dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")-65+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")-85+obj.offsetHeight+"px"

cr3ative

guymclaren
12-14-2004, 10:46 AM
Dankie
Siya bonga
Obrigado
Vielen Dank
Merci

and as many otherways as it is possible to say so.

Afrikaans
Zulu
Portuguese
German
French

and a Frohe Weinachten to you as well