日期:2014-05-16 浏览次数:20482 次
function loadScript(url, callback){ var script = document.createElement("script") script.type = "text/javascript"; if (script.readyState){ //IE script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; } else { //Others script.onload = function(){ callback(); }; } script.src = url; document.body.appendChild(script); }
(function($){ //定义功能函数 var RowSwitch = function(){ var rowSwitch = this; rowSwitch.init = function(){ …… }; rowSwitch.bind = function(){ $(".ptslist li a").click(function(e){ …… }); }; …… }; //绑定代码 $(function(){ var rowSwitch = new RowSwitch(); rowSwitch.init(); rowSwitch.bind(); }); })(jQuery);
(function ($) { var defaults = { …… }; $.fn.rollOver = function (options) { var settings = $.extend(true, {}, defaults, options); }); } $.fn.rollOver.defaults = defaults; })(jQuery); .... window.asyncCanary = 1; //文件结束标志
$async = function(canary){....} //异步检测函数定义,这里会定义一个timer,隔一断时间就会检测标志是否已定义; $async("asyncCanary", function(){ //检测asyncCanary,如果已定义则执行绑定 $("#menubar").rollOver({hoverTxt:""....}); });