1//plugin author:chenjinfa@gmail.com
2//Plugin Name: $.include
3//$.include (' file/ajaxa.js '); $.include (' file/ajaxa.css ');
4//or $.includepath = ' file/'; $.include ([' Ajaxa.js ', ' ajaxa.css ']);
5
6$.extend ({
7 Includepath: ',
8 Include:function (file) {
9 var files = typeof File = = "string"? [File]:file;
for (var i = 0; i < files.length; i++) {
One 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") + "= '" + $.includepath + name + "'";
if ($ (tag + "[" + link + "]"). Length = = 0 document.write ("<" + tag + attr + link + "></" + tag +) > ");
19}
20}
21});
On the head of the JavaScript file, just like C # (using ...). or Java (import ...). )
Example: Department Admin page Department.aspx
Note: Because of the editor's question, the content (http://www.cnblogs.com) is the original. . / . . /”
.
<link rel="stylesheet" href="http://www.cnblogs.com/css/common.css" type="text/css"/>
<script src="http://www.cnblogs.com/javascript/jquery.js" type="text/javascript"></script>
<script src="http://www.cnblogs.com/javascript/common.js" type="text/javascript"></script>
<script src="DepartmentInfo.js" type="text/javascript"></script>
The Include plugin code is placed in the public common.js.
Departmentinfo.js File Code
$.includePath = 'http://www.cnblogs.com/javascript/';
$.include(['json2.js', 'jquery.tree.js', 'jquery.tree.css']);
$(function() {
$("#depTree").tree({
url: "http://www.cnblogs.com/service/ES_SYSTEM.svc/DEP_INFO_Tree"
});
.
});
.
That's a pretty good way to do it.
Later I will be free to publish the whole project and experience I wrote. A framework system based on ASP.net Data Service and jquery, named "E-frame", realizes the function of role-based privilege system.