设为首页
优惠IDC
收藏本站
六狼博客
六狼论坛
开启辅助访问
切换到窄版
用户名
Email
自动登录
找回密码
密码
登录
立即注册
只需一步,快速开始
只需一步,快速开始
快捷导航
门户
首页
BBS
云计算
大数据
手机
移动开发android,ios,windows phone,windows mobile
编程
编程技术java,php,python,delphi,ruby,c,c++
前端
WEB前端htmlcss,javascript,jquery,html5
数据库
数据库开发Access,mysql,oracle,sql server,MongoDB
系统
操作系统windows,linux,unix,os,RedHat,tomcat
架构
项目管理
软件设计,架构设计,面向对象,设计模式,项目管理
企业
服务
运维实战
神马
搜索
搜索
热搜:
php
java
python
ruby
hadoop
sphinx
solr
ios
android
windows
centos
本版
帖子
用户
六狼论坛
»
首页
›
WEB前端
›
Html/Css
›
Ajax实现无刷新树
返回列表
查看:
89
|
回复:
0
Ajax实现无刷新树
[复制链接]
benben
benben
当前离线
积分
1774
窥视卡
雷达卡
升级
38.7%
当前用户组为
探花
当前积分为
1774
, 升到下一级还需要 1226 点。
580
主题
580
主题
580
主题
探花
探花, 积分 1774, 距离下一级还需 1226 积分
探花, 积分 1774, 距离下一级还需 1226 积分
积分
1774
发消息
楼主
|
发表于 2013-2-7 20:06:47
|
显示全部楼层
|
阅读模式
<div class="postText">
1.建立一个aspx页面
html代码
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee;">
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
id
="Head1"
runat
="server"
>
<
title
>
小山
</
title
>
<
link
type
="text/css"
href
="../../Styles/tree_css/tree.css"
rel
="stylesheet"
>
</
head
>
<
body
>
<
form
id
="Form1"
runat
="server"
>
<
table
width
=100%
cellpadding
=0
cellspacing
=0
border
=0
>
<
colgroup
>
<
col
width
=180
/>
<
col
/>
</
colgroup
>
<
tr
>
<
td
>
<
div
class
="TreeMenu"
id
="CategoryTree"
style
="width: 100%; height: 489px"
>
</
div
>
</
td
>
<
td
>
<
iframe
id
=furl
height
=20
style
="height: 497px; width: 100%;"
></
iframe
>
</
td
>
</
tr
>
</
table
>
<
script
language
="jscript"
>
function
el(id)
{
return
document.getElementById(id);
}
function
ExpandSubCategory(iCategoryID)
{
var
li_father
=
el(
"
li_
"
+
iCategoryID);
if
(li_father.getElementsByTagName(
"
li
"
).length
>
0
)
//
分类已下载
{
ChangeStatus(iCategoryID);
return
;
}
li_father.className
=
"
Opened
"
;
switchNote(iCategoryID,
true
);
AjaxMethod.GetSubCategory(iCategoryID, GetSubCategory_callback);
}
function
GetSubCategory_callback(response)
{
var
dt
=
response.value.Tables[
0
];
if
(dt.Rows.length
>
0
)
{
var
iCategoryID
=
dt.Rows[
0
].FatherID;
}
var
li_father
=
el(
"
li_
"
+
iCategoryID);
var
ul
=
document.createElement(
"
ul
"
);
for
(
var
i
=
0
;i
<
dt.Rows.length;i
++
)
{
if
(dt.Rows
.IsChild
==
1
)
//
叶子节点
{
var
li
=
document.createElement(
"
li
"
);
li.className
=
"
Child
"
;
li.id
=
"
li_
"
+
dt.Rows
.CategoryID;
var
img
=
document.createElement(
"
img
"
);
img.id
=
dt.Rows
.CategoryID;
img.className
=
"
s
"
;
img.src
=
"
../../Styles/tree_css/s.gif
"
;
var
a
=
document.createElement(
"
a
"
);
var
id
=
dt.Rows
.CategoryID;
a.onmouseover
=
function
()
{
PreviewImage(id);
}
;
a.href
=
"
javascript:OpenDocument('
"
+
dt.Rows
.CategoryID
+
"
');
"
;
a.innerHTML
=
dt.Rows
.CategoryName;
}
else
{
var
li
=
document.createElement(
"
li
"
);
li.className
=
"
Closed
"
;
li.id
=
"
li_
"
+
dt.Rows
.CategoryID;
var
img
=
document.createElement(
"
img
"
);
img.id
=
dt.Rows
.CategoryID;
img.className
=
"
s
"
;
img.src
=
"
../../Styles/tree_css/s.gif
"
;
img.onclick
=
function
()
{
ExpandSubCategory(
this
.id);
}
;
img.alt
=
"
展开/折叠
"
;
var
a
=
document.createElement(
"
a
"
);
a.href
=
"
javascript:ExpandSubCategory(
"
+
dt.Rows
.CategoryID
+
"
);
"
;
a.innerHTML
=
dt.Rows
.CategoryName;
}
li.appendChild(img);
li.appendChild(a);
ul.appendChild(li);
}
li_father.appendChild(ul);
switchNote(iCategoryID,
false
);
}
//
叶子节点的单击响应函数
function
OpenDocument(iCategoryID)
{
//
预加载信息
PreloadFormUrl(iCategoryID);
}
function
PreviewImage(iCategoryID)
{
}
function
ChangeStatus(iCategoryID)
回复
使用道具
举报
提升卡
置顶卡
沉默卡
喧嚣卡
变色卡
千斤顶
显身卡
返回列表
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
本版积分规则
发表回复
回帖后跳转到最后一页
Copyright © 2008-2020
六狼论坛
(http://it.6wolf.com) 版权所有 All Rights Reserved.
Powered by
Discuz!
X3.4
京ICP备14020293号-2
本网站内容均收集于互联网,如有问题请联系
QQ:389897944
予以删除
快速回复
返回顶部
返回列表