找回密码
 立即注册
首页 业界区 业界 JQuery实现经典网站后台框架

JQuery实现经典网站后台框架

袁可佳 2025-5-29 20:03:02
网站后台是每个网站必须的部分,使用一个好的框架也是给用户良好体验的一部分内容,本文将给大家介绍使用JQuery和JS实现的ASP.NET网站后台框架。
首先看看我们需要的资源:
1. FrameTab.js (文章结尾提供下载)

该文件主要功能是实现一个像IE 8中Tab页一样的功能,这个可以方便用户在一个浏览器页面里打开多个某快的后台内容,以及对其进行切换
2. jquery.pack.js (文章结尾提供下载)

这个JQuery的文件大家应该很熟悉了,不做解释了。
主要的文件都在上面了,下面先来搭建主题框架,如下html代码:
 
1.gif
2.gif
Default.aspx
3.gif
4.gif
 
5.gif

6.gif
 
7.gif
 
8.gif
 
9.gif
    零码软件服务(www.learnmark.com) 
10.gif
     
11.gif

12.gif
     
13.gif
     
14.gif
     
15.gif

16.gif
     
17.gif
     
18.gif
     
19.gif
 
20.gif
 
21.gif
     
22.gif
     
23.gif
         
24.gif
            [tr] 
25.gif
                 
26.gif
                     
27.gif
                         
28.gif
                            
29.gif
                                href="MyWorktable.htm" target="left">我的工作台 
30.gif
                             
31.gif
                            
32.gif
                                href="Components/SystemMenus/MenuTest.aspx" target="left"> 
33.gif
                                    系统  
34.gif
                            
35.gif
                                href="javascript:ShowMain('menu2.htm','')">系统 
36.gif
                             
37.gif
                             
38.gif
                                系统  
39.gif
                             
40.gif
                                客商  
41.gif
                            合同 
42.gif
                             
43.gif
                            项目 
44.gif
                             
45.gif
                            销售 
46.gif
                             
47.gif
                            采购 
48.gif
                             
49.gif
                            仓库 
50.gif
                             
51.gif
                            财务 
52.gif
                             
53.gif
                            管理 
54.gif
                             
55.gif
                            报表 
56.gif
                             
57.gif
                            帮助 
58.gif
                             
59.gif
                        </ul> 
60.gif
                         
61.gif
                             
62.gif
                                
     
    63.gif
                                        
  • 管理员:admin,欢迎您!    
    64.gif
                                        
  • 工作台首页 
    65.gif
                                         
    66.gif
                                        
  • 我的权限  
    67.gif
                                        
  • 使用帮助  
    68.gif
                                        
  • 安全退出  
    69.gif
                                    
 
70.gif
                             
71.gif
                         
72.gif
                     
73.gif
                [/td] 
74.gif
            [/tr] 
75.gif
             
76.gif
                 
77.gif
                     
78.gif
                [/td] 
79.gif
                 
80.gif
                     
81.gif
                [/td] 
82.gif
                [td] 
83.gif
                     
84.gif
                         
85.gif
                         
86.gif
                         
87.gif
                         
88.gif
                         
89.gif
                             
90.gif
                                我的工作台
91.gif
                                    class="closeTab">
  
92.gif
                                 
93.gif
                            </ul> 
94.gif
                         
95.gif
                     
96.gif
                     
97.gif
                     
98.gif
                         
99.gif
                         
100.gif
                         
101.gif
                     
102.gif
                [/td] 
103.gif
            [/tr] 
104.gif
         
105.gif
    [/table] 
106.gif
     
107.gif
         
108.gif
     
109.gif
     
110.gif
         
111.gif
     
112.gif
     
113.gif
 
114.gif

115.gif

116.gif
以上代码是整个框架,接下来我们来写一些常用的JS,这些JS我们放在AdminIndex.js中:
 
117.gif
118.gif
AdminIndex.js
119.gif
var displaymode = 0; 
120.gif
var StyleSheetPath, _BasePath, _adminPath, _adminName; 
121.gif
122.gif
function setStyleSheetPath(path) 
123.png
{ StyleSheetPath = path; } 
124.gif
125.gif
function setBasePath(basepath, adminpath) 
126.png
{ _BasePath = basepath; _adminPath = adminpath; } 
127.gif
128.gif
function setAdminName(adminname) 
129.png
{ _adminName = adminname; }; 
130.gif
//修改IE下document.getElementById在id和name同名时的bug 
131.gif
if (/msie/i.test(navigator.userAgent)) //根据userAgent确定用户使用IE浏览器 
132.gif
133.gif
134.png

135.gif
    document.nativeGetElementById = document.getElementById; 
136.gif
137.gif
    document.getElementById = function(id) 
138.png

139.gif
        var elem = document.nativeGetElementById(id); 
140.gif
141.gif
        if (elem) 
142.png
{              //修改后的确认能得到id属性方法 
143.gif
144.gif
            if (elem.attributes['id'].value == id) 
145.png

146.gif
                return elem; 
147.gif
148.gif
            } else 
149.png
{                  //如果没有ID相同的,那么就遍历所有元素的集合找到id相同的元素 
150.gif
151.gif
                for (var i = 1; i  0) 
152.png

153.gif
        cookieStart = document.cookie.indexOf(name + "=") 
154.gif
155.gif
        if (cookieStart != -1) 
156.png

157.gif
            cookieStart = cookieStart + name.length + 1 
158.gif
            cookieEnd = document.cookie.indexOf(";", cookieStart) 
159.gif
            if (cookieEnd == -1) cookieEnd = document.cookie.length 
160.gif
            return unescape(document.cookie.substring(cookieStart, cookieEnd)) 
161.gif
        } 
162.gif
    } 
163.gif
    return "" 
164.gif

165.gif

166.gif
//初始化菜单 
167.gif
168.gif
function onload() 
169.png

170.gif
    var width = document.body.clientWidth - 207; 
171.gif
    var lHeight = document.body.clientHeight - 78; 
172.gif
    var rHeight = lHeight - (jQuery("#FrameTabs").height() || 0); 
173.gif
    document.getElementById("main_right").style.width = width > 0 ? width : 0; 
174.gif
    document.getElementById("left").style.height = lHeight > 0 ? lHeight : 0; 
175.gif

176.gif

177.gif
178.gif
function jumpto(inputurl) 
179.png

180.gif
    if (document.getElementById && displaymode == 0) 
181.gif
        document.getElementById("main_right").src = inputurl 
182.gif
    else if (document.all && displaymode == 0) 
183.gif
        document.all.external.src = inputurl; 
184.gif
185.gif
    else 
186.png

187.gif
        if (!window.win2 || win2.closed) 
188.gif
            win2 = window.open(inputurl); 
189.gif
190.gif
        else 
191.png

192.gif
        } 
193.gif
    } 
194.gif

195.gif

196.gif
//创建菜单缓存 
197.gif
198.gif
function CreateSideBarCookie() 
199.png

200.gif
    var SideBarKey = document.getElementById("left").src.substring(document.getElementById("left").src.lastIndexOf('/') + 1, document.getElementById("left").src.lastIndexOf('.')); 
201.gif
    var SideBarValue; 
202.gif
203.gif
    if (document.getElementById("frmTitle")) 
204.png

205.gif
206.gif
        if (SideBarValue = document.getElementById("frmTitle").style.display == "") 
207.png

208.gif
            SideBarValue = "block"; 
209.gif
        } 
210.gif
211.gif
        else 
212.png

213.gif
            SideBarValue = document.getElementById("frmTitle").style.display; 
214.gif
        } 
215.gif
    } 
216.gif
    var existentSideBarCookie = getCookie("SideBarCookie"); 
217.gif
218.gif
    if (SideBarKey.length != 0 && SideBarValue.length != 0) 
219.png

220.gif
        var temp = ""; 
221.gif
        var SideBarKV = existentSideBarCookie; 
222.gif
223.gif
        if (existentSideBarCookie.length != 0) 
224.png

225.gif
226.gif
            if (SideBarKV.indexOf(SideBarKey) != -1) 
227.png

228.gif
                var arrKV = existentSideBarCookie.split("&"); 
229.gif
230.gif
                for (var v in arrKV) 
231.png

232.gif
233.gif
                    if (arrKV[v].indexOf(SideBarKey) != -1) 
234.png

235.gif
                        temp = existentSideBarCookie.replace(arrKV[v], SideBarKey + "=" + SideBarValue); 
236.gif
                    } 
237.gif
                } 
238.gif
            } 
239.gif
240.gif
            else 
241.png

242.gif
                temp = SideBarKey + "=" + SideBarValue + "&" + existentSideBarCookie; 
243.gif
            } 
244.gif
        } 
245.gif
246.gif
        else 
247.png

248.gif
            temp = SideBarKey + "=" + SideBarValue; 
249.gif
        } 
250.gif
        setCookie("SideBarCookie", temp, 300, "/", "", false); 
251.gif
    } 
252.gif
253.gif
    else 
254.png

255.gif
        return ""; 
256.gif
    } 
257.gif

258.gif

259.gif
//恢复菜单 
260.gif
261.gif
function InitSideBarState() 
262.png

263.gif
    var existentSideBarCookie = getCookie("SideBarCookie"); 
264.gif
    var SideBarKey = document.getElementById("left").src.substring(document.getElementById("left").src.lastIndexOf('/') + 1, document.getElementById("left").src.lastIndexOf('.')); 
265.gif
266.gif
    if (existentSideBarCookie.length != 0 && SideBarKey.length != 0 && existentSideBarCookie.indexOf(SideBarKey) != -1) 
267.png

268.gif
        var arrKV = existentSideBarCookie.split("&"); 
269.gif
270.gif
        for (var v in arrKV) 
271.png

272.gif
273.gif
            if (arrKV[v].indexOf(SideBarKey) != -1) 
274.png

275.gif
                var currentValue = arrKV[v].split("="); 
276.gif
                ChangeSideBarState(currentValue[1]); 
277.gif
            } 
278.gif
        } 
279.gif
    } 
280.gif
281.gif
    else 
282.png

283.gif
        var obj = document.getElementById("switchPoint"); 
284.gif
        obj.alt = "关闭左栏"; 
285.gif
        obj.src = "Images/butClose.gif"; 
286.gif
        document.getElementById("frmTitle").style.display = "block"; 
287.gif
        onload(); 
288.gif
    } 
289.gif

290.gif

291.gif

292.gif
//显示或隐藏菜单 
293.gif
294.gif
function ChangeSideBarState(temp) 
295.png

296.gif
    var obj = document.getElementById("switchPoint"); 
297.gif
298.gif
    if (temp == "none") 
299.png

300.gif
        obj.alt = "打开左栏"; 
301.gif
        obj.src = "Images/butOpen.gif"; 
302.gif
        document.getElementById("frmTitle").style.display = "none"; 
303.gif
        var width, height; 
304.gif
        width = document.body.clientWidth - 12; 
305.gif
        height = document.body.clientHeight - 70; 
306.gif
        document.getElementById("main_right").style.height = height; 
307.gif
        document.getElementById("main_right").style.width = width; 
308.gif
        document.getElementById("FrameTabs").style.width = width; 
309.gif
310.gif
        if (CheckFramesScroll) 
311.png
{ CheckFramesScroll(); } 
312.gif
    } 
313.gif
314.gif
    else 
315.png

316.gif
        obj.alt = "关闭左栏"; 
317.gif
        obj.src = "Images/butClose.gif"; 
318.gif
        document.getElementById("frmTitle").style.display = "block"; 
319.gif
        onload(); 
320.gif
    } 
321.gif

322.gif

323.gif
//显示菜单及内容 
324.gif
325.gif
function ShowMain(FileName_Left, FileName_Right) 
326.png

327.gif
    var temp; 
328.gif
329.gif
    if (FileName_Left != "") 
330.png

331.gif
        var checkLeftUrl = CheckCurrentLeftUrl(FileName_Left); 
332.gif
333.gif
        if (checkLeftUrl == "false") 
334.png

335.gif
            temp = document.getElementById("left"); 
336.gif
            temp.src = FileName_Left + GetUrlParm(FileName_Left); 
337.gif
            temp.contentWindow.window.name = "left"; 
338.gif
            frames["left"] = temp.contentWindow.window; 
339.gif
        } 
340.gif
    } 
341.gif
342.gif
    if (FileName_Right != "") 
343.png

344.gif
        temp = document.getElementById("main_right"); 
345.gif
        temp.src = FileName_Right + GetUrlParm(FileName_Right); 
346.gif
        temp.contentWindow.window.name = "main_right"; 
347.gif
        frames["main_right"] = temp.contentWindow.window; 
348.gif
    } 
349.gif
    InitSideBarState(); 
350.gif

351.gif

352.gif
353.gif
function CheckCurrentLeftUrl(leftUrl) 
354.png

355.gif
    var src = document.getElementById("left").src; 
356.gif
    var regex = /\s*[\?&]{1,1}t=[0-9]{1,}$/; 
357.gif
    var currentLeftUrl = src.replace(regex, ''); 
358.gif
359.gif
    if (currentLeftUrl.lastIndexOf(leftUrl) >= 0) 
360.png

361.gif
362.gif
        if (currentLeftUrl.lastIndexOf(leftUrl) == (currentLeftUrl.length - leftUrl.length)) 
363.png

364.gif
            return "true"; 
365.gif
        } 
366.gif
    } 
367.gif
    return "false"; 
368.gif

369.gif

370.gif
371.gif
function GetUrlParm(url) 
372.png

373.gif
    var urlparm = "?"; 
374.gif
375.gif
    if (url.indexOf('?') >= 0) 
376.png

377.gif
        urlparm = "&"; 
378.gif
    } 
379.gif
    urlparm = urlparm + "t=" + GetRandomNum(); 
380.gif
    return urlparm; 
381.gif

382.gif

383.gif
384.gif
function GetRandomNum() 
385.png

386.gif
    var Range = 1000; 
387.gif
    var Rand = Math.random(); 
388.gif
    return (Math.round(Rand * Range)); 
389.gif

390.gif

391.gif
392.gif
function switchSysBar() 
393.png

394.gif
    var obj = document.getElementById("switchPoint"); 
395.gif
396.gif
    if (obj.alt == "关闭左栏") 
397.png

398.gif
        obj.alt = "打开左栏"; 
399.gif
        obj.src = "/Images/butOpen.gif"; 
400.gif
        document.getElementById("frmTitle").style.display = "none"; 
401.gif
        var width, height; 
402.gif
        width = document.body.clientWidth - 12; 
403.gif
        height = document.body.clientHeight - 70; 
404.gif
        document.getElementById("main_right").style.height = height; 
405.gif
        document.getElementById("main_right").style.width = width; 
406.gif
        document.getElementById("FrameTabs").style.width = width; 
407.gif
408.gif
        if (CheckFramesScroll) 
409.png
{ CheckFramesScroll(); } 
410.gif
    } 
411.gif
412.gif
    else 
413.png

414.gif
        obj.alt = "关闭左栏"; 
415.gif
        obj.src = "/Images/butClose.gif"; 
416.gif
        document.getElementById("frmTitle").style.display = ""; 
417.gif
        onload(); 
418.gif
    } 
419.gif
    CreateSideBarCookie(); 
420.gif

421.gif

422.gif
//设置选中菜单样式 
423.gif
var tID = ""; 
424.gif

425.gif
426.gif
function ShowHideLayer(ID) 
427.png

428.gif
429.gif
    if (ID != tID) 
430.png

431.gif
        var triangle = document.getElementById("MenuMyDeskTopMore_Triangle"); 
432.gif
433.gif
        if (tID != "") 
434.png

435.gif
            document.getElementById("A" + tID).style.backgroundImage = "url(/Images/digital_left.gif)"; 
436.gif
437.gif
            if (document.getElementById("A" + tID).childNodes.length  
438.gif
 
439.gif
 
440.gif
 
441.gif
 
442.gif
 
443.gif
 
444.gif
    快捷导航 
445.gif
 
446.gif

447.gif
448.gif
     
449.gif
450.gif
 
451.gif
 
452.gif
 
453.gif
     
454.gif
         
455.gif
            
     
    456.gif
                     
    457.gif
                         
    458.gif
        系统管理 
    459.gif

    460.gif
                         
    461.gif
                     
    462.gif
                     
    463.gif
                         
    464.gif
         
    465.gif
            系统管理 
    466.gif
         
    467.gif
            
       
      468.gif
                  
    • 用户与权限 
      469.gif
                  
    • 管理员配置 
      470.gif
                  
    • 基础数据 
      471.gif
                  
    • 编号规则 
      472.gif
                  
    • 公司信息 
      473.gif
                  
    • 员工信息 
      474.gif
                  
    • 部门信息 
      475.gif
                  
    • 修改密码 
      476.gif
                  
    • 个性配置 
      477.gif
                  
    • 网格颜色配置 
      478.gif
                  
    • 合同多级分类 
      479.gif
                  
    • 标准业务问题分类 
      480.gif
                  
    • 商品多级分类 
      481.gif
                  
    • 合同模板分类 
      482.gif
                  
    • 文件分类 
      483.gif
                  
    • 收支科目分类 
      484.gif
                  
    • 数据导入 
      485.gif
                  
    • 数据反审核 
      486.gif
                  
    • 业务移交 
      487.gif
                  
    • 退出系统 
      488.gif
              
     
    489.gif
         
    490.gif
                         
    491.gif
                     
    492.gif
                     
    493.gif
                
 
494.gif
         
495.gif
     
496.gif
 
497.gif

498.gif

499.gif
这样完成后基本内容就实现了,然后根据自己的喜好和网站的风格美化一下就完成了。
具体代码下载:点击下载

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
您需要登录后才可以回帖 登录 | 立即注册