Hi!
SmartMenus
smartmenus at smartmenus.org
Tue May 13 13:10:39 BST 2003
Hi guys,
I am sorry to bother you!
I have two small problems with Konqueror 3.1.0 and I thought you might know a
solution. I am not able to find the real position of an element (image in my
particular case) on the page. I am trying with the well known while cycle and
offsetTop, offsetLeft, offsetParent method but I can't achieve a good result if
my image is nested inside some tables. With Konqueror 3.0.0 this method used to
return almost perfect values (for the same example) for top and left (still
there were some wrong pixels counted) but now it returns "very" incorrect
values :(.
Below is the function I use specially for Konqueror 3.1.0+. You can see live
example at http://www.smartmenus.org by clicking the fake select box
inside "YOUR OPINION" on the left.
-----------
function rateCds(x_or_y){
var o=document.images['rate'];
var oP,oC;
oP=o.offsetParent;
C=x_or_y=='x'?o.offsetLeft:o.offsetTop;
while(oP){
oC+=x_or_y=='x'?oP.offsetLeft:oP.offsetTop;
oP=oP.offsetParent
};
return x_or_y=='x'?
(
document.body.style&&document.body.style.marginLeft?
parseInt(document.body.style.marginLeft)+oC:
document.body.marginWidth?
parseInt(document.body.marginWidth)+oC:
document.body.leftMargin?
parseInt(document.body.leftMargin)+oC:
oC+10
):
(
document.body.style&&document.body.style.marginTop?
parseInt(document.body.style.marginTop)+oC:
document.body.marginHeight?
parseInt(document.body.marginHeight)+oC:
document.body.topMargin?
parseInt(document.body.topMargin)+oC:
oC+10
)
}
-----------
You can also see that at the end I am checking for all variants that allow a
margin to be defined for the BODY. This is another thing I don't like so much
in Konqueror 3.1.0. We could easily get the BODY margin with
document.body.offsetTop(Left) in Konqueror 3.0.0 and now this is changed.
I would be really very grateful and thankful if you could spend some time and
answer me. Please let me know if there's something wrong I am doing for finding
the position of the image and if there's any easier way to get the real body
margin without doing all those checks.
Thank you for the time spent reading this! I will appreciate any response.
Sincerely,
Vasil Dinkov.
Plovdiv, Bulgaria.
smartmenus at smartmenus.org
http://www.smartmenus.org/
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
More information about the kfm-devel
mailing list