OnLoad no longer works after maps script inclusion

222 views
Skip to first unread message

LCID Fire

unread,
Dec 2, 2009, 3:45:13 PM12/2/09
to Google Maps JavaScript API v3
Since 2 days now I'm struggling with a problem - when I include the
google script in my site the onload event no longer works - when I
remove or outcomment the script I get my alert dummy again.
I'm pretty sure that I missed something obvious - but I seem kinda
blind. Would be great if someone could point me in the right direction

<!DOCTYPE html PUBLIC "-//W3C//DTD xhtml 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tryout</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/
js?sensor=false"/>
<script type="text/javascript">
function test()
{
alert("ME");
}
</script>
</head>
<body onLoad="test();">
<div><button name="submitpoint" type="button"><div id="map_canvas"/
></button></div>
</body>
</html>

Bob

unread,
Dec 2, 2009, 5:34:03 PM12/2/09
to Google Maps JavaScript API v3
You forgot an ending '</script>' tag after '<script type="text/
javascript" src="http://maps.google.com/maps/api/> js?sensor=false"/
>'. Browsers require that even when loading external scripts

Bob

unread,
Dec 2, 2009, 5:37:12 PM12/2/09
to Google Maps JavaScript API v3
Sorry, didn't notice your attempt to end it the XML way with "/>". I
don't think the script tag is considered a single instant like that.
At least, browsers seem to ignore that and want the full '</script>'
ending.

yunhui song

unread,
Dec 2, 2009, 6:02:19 PM12/2/09
to google-map...@googlegroups.com
Same problem here. The only working solution for me now is don't use onload.

I'm using jQuery

$(document).ready(){
}

instead of onload(){
}

Good luck.
Sammi
> --
>
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>
>

LCID Fire

unread,
Dec 3, 2009, 1:45:55 AM12/3/09
to Google Maps JavaScript API v3
You're right - adding a full fledged '</script>' makes the whole thing
work. IMO - writing it this way is quite strange - but since even lynx
is handling the script tag that way I wonder whether this is defined
in the standard (and above all - why it would be).
Anyway - thanks a lot.
Reply all
Reply to author
Forward
0 new messages