<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>js调用</title> <script src="cssjs/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $().ready(function () { $.dialog = function (settings) { if ($.isFunction(settings.okCallback)) { if (settings.height == null) { if (settings.okCallback.apply() != false) { alert("1"); } } else { if (settings.okCallback.call(this, settings.height) != false) { alert("2"); } /* if (settings.okCallback.apply(this, arguments) != false) { alert("2"); } */ } } } }); </script> <script type="text/javascript"> $(function () { $.dialog({ okCallback: print, height: {data:"你好"} }); }); function print(ee1) { alert("print(ee1)"); alert(ee1.data); /* alert(ee1.height.data); */ } /* function print(a, b, c, d) { alert(a + b + c + d); } function example(a, b, c, d) { //用call方式借用print,参数显式打散传递 print.call(this, a, b, c, d); //用apply方式借用print, 参数作为一个数组传递, //这里直接用JavaScript方法内本身有的arguments数组 print.apply(this, arguments); //或者封装成数组 print.apply(this, [a, b, c, d]); } //下面将显示"背光脚本" example("背", "光", "脚", "本"); */ </script> </head> <body> </body> </html>