sample callback function

 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 2         "http://www.w3.org/TR/html4/loose.dtd">
 3 <html>
 4 <head>
 5     <title>callbackTest</title>
 6
 7     <script type="text/javascript">
 8         function main(callback){
 9             alert("i am main function");
10             alert("invoke callback function");
11             callback();
12         }
13
14         function b(){
15             alert("i am callback function b");
16         }
17
18         function c(){
19             alert("i am callback function c");
20         }
21
22         function test(){
23             main(b);
24             main(c);
25         }
26     </script>
27 </head>
28 <body>
29 <button onclick="test()"> click me</button>
30 </body>
31 </html>
时间: 2024-08-09 15:35:06

sample callback function的相关文章

(C/C++) Callback Function

原文: http://www.codeguru.com/cpp/cpp/cpp_mfc/callbacks/article.php/c10557/Callback-Functions-Tutorial.htm Callback Functions Tutorial Introduction If you are reading this article, you probably wonder what callback functions are. This article explains

理解callback function in javascript

以下内容主要摘自[1,2] (1)In javascript, functions are first-class objects, which means functions can be used in a first-class manner like objects, since they are in fact objects themselves: They can be “stored in variables, passed as arguments to functions,

Callback Function

typedef void (*callbackFun)(int a, int b);struct exm { int type; callbackFun fun;}; A pointer is a special kind of variable that holds the address of another variable. The same concept applies to function pointers, except that instead of pointing to

C语言中的回调函数(Callback Function)

1 定义和使用场合 回调函数是指 使用者自己定义一个函数,实现这个函数的程序内容,然后把这个函数(入口地址)作为参数传入别人(或系统)的函数中,由别人(或系统)的函数在运行时来调用的函数.函数是你实现的,但由别人(或系统)的函数在运行时通过参数传递的方式调用,这就是所谓的回调函数.简单来说,就是由别人的函数运行期间来回调你实现的函数. 这一设计允许了底层代码调用在高层定义的子程序(如图1-1所示).C语言中回调函数主要通过函数指针的方式实现. 图1-1 回调函数在软件系统的调用结果 回调的用途十

gevent: AssertionError: Impossible to call blocking function in the event loop callback

今天在用爬虫时gevent报了AssertionError: Impossible to call blocking function in the event loop callback 异常,很奇怪,难道是patch_socket惹的货,因为之前没有使用patch_socket是正常的,代码简化如下 import urllib import gevent from gevent.monkey import patch_socket from gevent.hub import get_hub

全面理解Javascript中Function对象的属性和方法

函数是 JavaScript 中的基本数据类型,在函数这个对象上定义了一些属性和方法,下面我们逐一来介绍这些属性和方法,这对于理解Javascript的继承机制具有一定的帮助. 属性(Properties) arguments 获取当前正在执行的 Function 对象的所有参数,是一个类似数组但不是数组的对象,说它类似数组是因为其具有数组一样的访问性质及方式,可以由arguments[n]来访问对应的单个参数的值,并拥有数组长度属性length.还有就是arguments对象存储的是实际传递给

[工作积累] Android system dialog with native callback

JNI: invoke java dialog with native callback: store native function address in java, and invoke native another method to this function. key points: 1.Store callback function pointer(address) in java: to support multiple calls, use data block for each

Asynchronous function in a while-loop

I have a question about how to perform an asynchronous task in a while-loop until some condition is met. This is more of a theoretical question but I can see how this could be an issue in some scenarios. I'll try demonstrate the problem at an example

js中callback.call()和callback()的区别

js中callback.call()和callback()的区别在js中callback.call()和callback() 有什么区别,举个例子:function a(){alert('hello!');}function b(callback){callback();}function c(callback){callback.call();}function test(){b(a);c(a);}在test函数中,b和c的效果是一样的,都执行了回调函数a.这两种用法有什么区别呢? -----