最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the function of google.maps.event.addDomListener(window, 'load', initialize);? - Stack Over

programmeradmin1浏览0评论

I was trying Google maps. I found this statement.

google.maps.event.addDomListener(window, 'load', initialize);

what is the function of that statement ?

I was trying Google maps. I found this statement.

google.maps.event.addDomListener(window, 'load', initialize);

what is the function of that statement ?

Share Improve this question edited Jul 19, 2013 at 9:14 Sathyajith Bhat 21.9k22 gold badges99 silver badges139 bronze badges asked Jul 19, 2013 at 9:13 Daniel Listyo EmanuelDaniel Listyo Emanuel 3371 gold badge6 silver badges13 bronze badges 2
  • from the looks of it, it adds a call to "initialize" when the DOM is loaded. – Thilo Commented Jul 19, 2013 at 9:16
  • it runs the function 'initialize' when the window 'load' event is fired? – EvilEpidemic Commented Jul 19, 2013 at 9:17
Add a comment  | 

2 Answers 2

Reset to default 13

It adds a listener to the window object, which as soon as the load event is triggered (i.e. "the page has finished loading") executes the function initialize.

I.e. it delays the Google Map related script until the page has finished loading.

@Dust function is initialize and it is called only after the <div> element is loaded. in maps.event..., I think event is element because essentially it contains the map-canvas information.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论