I am trying to identify how I can find out where a specific element (e.g. a
<div> or a <img> ) appears within a page. I want to position some else
immediately after the <element> and so need to know where it begins!
That's unlikely. The `div' or `img' element would then be have to be
positioned absolute or floating with CSS. If it was not positioned absolute
and not floating you could simply insert the new element node right after
the target element node:
if (target.nextSibling)
{
target.insertBefore(newElementNode, target.nextSibling);
}
else
{
target.parentNode.appendChild(newElementNode);
}
How you can obtain the `target' reference depends on your markup, and how
you can obtain the `newElementNode' reference depends on the element type
("tag name").
I can't use the x / y co-ordinates as this just tells me where the mouse is.
Parse error.
Finding out the rendering position of an element is not a trivial task (and,
from what I can see, probably way over your head) as there are many aspects
to watch for, including but not limited to different box models. If you
really need that (see above), you should search the archives for it, see
<
http://jibbering.com/faq/> or acquire the necessary knowledge by reading
much more documentation than you did for this question.
PointedEars