Code:
<circle id="whitecircle" cx="500" cy="500" r="25" fill="url(#grad1)" onclick="setCoordinates(evt)" />
This works perfectly well. “setCoordinates(evt)” function gives the circle a random position when it is clicked on.
However, when I replay “onclick” with “onload”, it just stays at “500,500”.
Why is this?
The element isn’t loading any external content. Since there is nothing to load, it doesn’t have a load event.
You can just run a script immediately after defining the circle element.
(the HTML
bodyelement is a special case, representing the current document)