View Full Version : Locating elements

01-11-2006, 06:39 PM
I found a script which very simply reveals a div by id. but I can't get the location just right. It needs to be relative to the object that invokes it through mouseover. Take a look here (http://upcondos.com/CGW_Test/Suncrest.shtml), mouseover the 'Features' item on the far right. You'll see that I've got the vertical position worked out, although I don't like the way I did it (not dynamic enough), but the horizontal position varies with the width of the window; I want it to be constant relative to the object that invokes it.

Here's the script:

function showtip(current, whichDiv, whichParent)
elm=document.getElementById( whichDiv );
thisParent=document.getElementById( whichParent );
elm.style.visibility = "visible";

Thanks in advance. Any help will be greatly appreciated.

01-12-2006, 08:05 AM
Your code doesn't work in FF. Also offsetHeight, offsetWidth, etc are already integers so the parseInt() method is a waste of time for them. If you really would like to know more about finding the position of things, check out:

Find position (http://www.quirksmode.org/js/findpos.html)

from Quirksmode's website. Once you have your target element (http://www.quirksmode.org/js/events_properties.html#target)'s position properly identified, a fixed number of pixels distance from it will be where you want to position your pop up division.