I am currently in the process of writing a script that will position all html (or other appropriate tag) elements on screen dynamically. I have seen a number of examples on the net demonstrating how to reposition an element after a mouseover event, and other interesting (cool) effects. The thing is I want to position my elements with three peices of information, the elements id, an x coordinate and a y coordinate. At this stage I am still a DOM novice so I am trying to work out the correct methods (etc) to use. This having been said I am facing a larger challenge in that I want my script to be called multiple times, each time being passed a different page element. This is probably not that big a deal however, the script needs to be called when the page loads not when a special event, like mouseover, takes place.
My code looks like the following....
<title> Simple Element Positioning Script </title>
// Set an indicator variable to determine DOM supported by current browser.
var domIndicator = 0;
// IE5+ or NS6+ Browser detected.
domIndicator = 1;
// IE4 Browser detected.
domIndicator = 2;
// NS4 Browser detected.
domIndicator = 3;
function posElem(elementID, xPos, yPos)
if(domIndicator == 1)
if(domIndicator == 2)
if(domIndicator == 3)
<img id="car" src="car.jpg">
// I don't think that the top level scripts posElem() function can be
// referenced from down here!
posElem('car', '100', '100');
Is it possible to call my posElem() function (declared in the head section) from the <script> code snippet that follows the <img> tag? Also are there any broad suggestions or pointers that you could give me to help me achieve my goals with this script. Any help will be greatly appreciated. Thanks for your time.