google.setOnLoadCallback(初始化)函数究竟意味着什么?

Abh*_*raj 9 javascript search-engine google-api

编写JavaScript和Ajax时,没有适合此功能的文档.我使用api src="http://www.google.com/jsapi"和搜索这个术语searchControl.execute("abhilashm86");.

这怎么google.setOnLoadCallback(initialize)称为内部?当用户清除以前的搜索并开始新的搜索时,此功能是否仅适用于新的搜索字词?如何google.setOnLoadCallback(initialize)得到trigerred?

Mat*_*hen 10

当您的文档(包括Google API)完全加载时,将调用您的初始化函数.因此,您应该在传入的函数中包装使用API​​的任何代码:

例如

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