google.setOnLoadCallback(初始化)函数究竟意味着什么? [英] What does google.setOnLoadCallback(initialize) function exactly mean?

查看:201
本文介绍了google.setOnLoadCallback(初始化)函数究竟意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写JavaScript和Ajax时,这个函数没有适当的文档。我用 api src =http://www.google.com/jsapi searchControl.execute(abhilashm86)搜索了这个词。



这是如何在内部调用 google.setOnLoadCallback(initialize)?当用户清除之前的搜索并启动一个新的搜索项时,该功能是否仅用于新的搜索项?
google.setOnLoadCallback(initialize)如何得到trigerred?

解决方案

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

  google.setOnLoadCallback(function()
{
var searcher = new google.search.SearchControl( );
//更多的代码依赖于API
});


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?

解决方案

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.
});

这篇关于google.setOnLoadCallback(初始化)函数究竟意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆