Forum Moderators: open

Message Too Old, No Replies

Finding absolute location of an element

How Ask.com does it.

         

krakrazor

10:12 am on Apr 2, 2006 (gmt 0)

10+ Year Member



check out this link, [ask.com...] on the new "binocular" feature, the site knows exactly where to pop-up the pictures previews.

How do i go about doing this?

I have created a pop-over function that does something like this but i can't seem to figure out how to position it based on the position of an image or a href link.

here is the my code:
function PopupMe()
{
if (!dom&&!ie&&!ns4)
{
window.open("http://www.google.com/", "", "scrollbars=1")
}
else
{
crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
crossframe=(dom)?document.getElementById("cframe") : ie? document.all.cframe : document.cframe
crossframe.src="http://www.google.com/"
crossframe.align="left"
crossobj.position="absolute"
crossobj.left="500"
crossobj.visibility=(dom¦¦ie)? "visible" : "show"
}
}

DrDoc

6:56 pm on Apr 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need to know the absolute positioning of an element. You can just position it relatively to the binoculars image, for example.

krakrazor

7:25 pm on Apr 2, 2006 (gmt 0)

10+ Year Member



How would i do such a thing?

DrDoc

7:31 pm on Apr 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<div style="position: relative;"><img> <div style="position: absolute; top: -100px; left: 50px;">binoculars effect here</div></div>

The second div is now positioned in reference to the parent wrapping div.