此文適合JavaScript入門級選手閱讀
先扯點閒話
在JavaScript裡什麼叫Callback“回調函數”
<html>
<head>
<title>Callback function test</title>
<script language="javascript" type="text/javascript">
function main(callback)
{
alert("I am main function");
alert("Invoke callback function
callback();
}
function b(){
alert("I am callback function: b");
}
function c(){
alert("I am callback function: c");
}
function test() {
main(b);
main(c);
}
</script>
</head>
<body>
<button onClick="test()">click me</button>
</body>
</html>
這 裡面main(b)
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19927.html