Forum Moderators: open

Message Too Old, No Replies

Browser processes events before necessary code loaded?

         

zinbiel

11:25 pm on Sep 23, 2004 (gmt 0)



I encountered a problem that appears to occur while a page loads. I have an image map, with areas that have onmouseover and onmouseout events. What happens is this:

When I move the mouse (back and forth) over the image map, while the page is loading, I get JavaScript errors. The errors state that function myFunc is not defined. However, the code is defined on the page and works when the page is loaded.

It appears that the browser tries to process the events before the necessary code is loaded.

Any ideas toward a solution will be very much appreciated.

hunkymonkey

11:32 pm on Sep 23, 2004 (gmt 0)

10+ Year Member



Is your javascript code before your image map? It should be.

If that still doesn't help, you could put your image map in a div tag and set the style to invisible, and then use the body's onload event handler to set the div to visible.

Just a thought! ;)

Rambo Tribble

1:44 am on Sep 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your functions should be defined in the head of the document and make sure the script tag doesn't include a defer attribute.