Загрузка окна API Google Maps V3 в некоторых браузерах не работает. - PullRequest
1 голос
/ 11 августа 2011

Странное поведение: последняя часть Документации о событиях внутри API карт говорит, что

>  If you've been reading the documentation this far, you're probably
> already familiar with one DOM event: the window.onload event, which
> we've handled within the <body> tag. We use this event to trigger the
> initial Javascript code once an HTML page is fully loaded, as shown
> below: <script>   function initialize() {
> 
>     // Map initialization
> 
>   } </script> <body onload="initialize()">   <div
> id="map_canvas"></div> </body> Although this event is attached to the
> <body> element here, this event is really a window event indicating
> that the DOM hierarchy below the window element has been fully built
> out and rendered. Although easy to understand, having an onload event
> within a <body> tag mixes content with behavior. Generally, it is good
> practice to separate your content code (HTML) from your behavioral
> code (Javascript) and provide your presentation code (CSS) separately
> as well. You can do so by replacing the inline onload event handler
> with a DOM listener within your Maps API Javascript code like so:
> <script>   function initialize() {
> 
>     // Map initialization
> 
>   }
>      google.maps.event.addDomListener(window, 'load', initialize);
> </script> <body>   <div id="map_canvas"></div> </body>

Почему-то google.maps.event.addDomListener(window, 'load', initialize); не работает для Firefox / Safari, но <body onload="initialize()"> делает ... Есть идеи почему?

...