日期:2014-05-16 浏览次数:20384 次
//jquery.common.js里面的方法 include: function (file) { var files = typeof file == "string" ? [file] : file; for (var i = 0; i < files.length; i++) { var name = files[i].replace(/^\s|\s$/g, ""); var att = name.split('.'); var ext = att[att.length - 1].toLowerCase(); var isCSS = ext == "css"; var tag = isCSS ? "link" : "script"; var attr = isCSS ? " type='text/css' rel='stylesheet' " : " language='javascript' type='text/javascript' "; var link = (isCSS ? "href" : "src") + "='" + name + "'"; if ($(tag + "[" + link + "]").length == 0) { if (isCSS) { var head = document.getElementsByTagName("head").item(0); var css = document.createElement("link"); css.href = name; css.rel = "stylesheet"; css.type = "text/css"; head.appendChild(css); } else { $.ajax({ type: 'GET', url: name, async: false, dataType: 'script' }); } } } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>测试页面</title> <script src="jquery-1.8.0-vsdoc.js" language="javascript" type="text/javascript" charset="utf-8"></script> <script src="jquery.common.js" language="javascript" type="text/javascript" ></script> </head> <body> <script language="javascript" type="text/javascript"> $(function(){ $.include(["/Dialog2/skins/default.css", "/Dialog2/jquery.artDialog.js"]); }); function test() { if (typeof ($.dialog) == undefined|| ($.dialog==null)) { alert(22); setTimeout(function () { $.dialog.alert("正在加载..."); }, 2000); } else { $.dialog.alert("正在加载..."); } } </script> <input type="button" value="获取dialog对象" onclick="test();"/> </body>