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

javascript - What does google.setOnLoadCallback(initialize) function exactly mean? - Stack Overflow

programmeradmin1浏览0评论

While coding JavaScript and Ajax, there is no proper documentation for this function. I searched this term using api src="" and searchControl.execute("abhilashm86");.

How is this google.setOnLoadCallback(initialize) called internally? Is this function just for a new search term when the user clears previous search and starts a new one? How exactly does google.setOnLoadCallback(initialize) get trigerred?

While coding JavaScript and Ajax, there is no proper documentation for this function. I searched this term using api src="http://www.google.com/jsapi" and searchControl.execute("abhilashm86");.

How is this google.setOnLoadCallback(initialize) called internally? Is this function just for a new search term when the user clears previous search and starts a new one? How exactly does google.setOnLoadCallback(initialize) get trigerred?

Share Improve this question edited Dec 15, 2011 at 23:34 makes 6,5483 gold badges41 silver badges59 bronze badges asked Apr 4, 2010 at 4:19 Abhilash MuthurajAbhilash Muthuraj 2,0289 gold badges34 silver badges50 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 10

Your initialize function will be called when your document (including the Google API) is fully loaded. So you should wrap any code that uses the API in the function you pass in:

E.g.

google.setOnLoadCallback(function()
{
   var searcher = new google.search.SearchControl();
   // More code that depends on the API.
});

The documentation says:

Use google.setOnLoadCallback to register the specified handler function to be called once the document loads instead of GSearch.setOnLoadCallback.

发布评论

评论列表(0)

  1. 暂无评论