<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试</title>
<script language="javascript" type="text/javascript" src="jquery.min.js"></script><!-- 引用jQuery库文件 -->
<script language="javascript" type="text/javascript">
$(document).ready(function(){
_Ajax_load_File(this,'demoData'/*为要访问的目录文件名称*/,'t2.jsp','onload');
})
//设置全局脚本变量
var datas = "";
var script = "";
function _Ajax_load_File(obj,data,src,action)
{
datas = encodeURI(encodeURI("dir=" + data));
script = src;
$.ajax({
type:"POST",
url:script,
data:datas,
cache: false,
success: function(msg)
{
if(action=='onload')
{
$("#fileTreeDemo_1").append(msg);
}
else
{
$(obj).parent().append(msg);
$(obj).parent().removeClass('wait');
}
}
});
}
function _Ajax_File(obj,con,sr)
{
if(con=='dir')//判断点击的是文件夹
{
//判断文件是否展开
if($(obj).parent().hasClass('directory-open'))
{
$(obj).parent().removeClass('directory-open');
$(obj).parent().find('ul').remove();//删除层
}
else
{
$(obj).parent().addClass('directory-open');
$(obj).parent().addClass('wait');
_Ajax_load_File(obj,sr,script,'click');
}
}
else
{
alert(sr);//输出文件路径
}
return;
}
</script>
<style>
<!--
.Tree_box {width:300px;height:500px;background:#FFF;border:#999 solid 1px;overflow:auto;}
.L {float:left;}
.FileTree { font-family: Verdana, sans-serif;
font-size: 11px;
line-height: 18px;
padding: 0px;
margin: 0px;}
.FileTree li { list-style: none;
padding: 0px;
padding-left: 20px;
margin: 0px;
white-space: nowrap;}
.FileTree li a { color: #333;
text-decoration: none;
display: block;
padding: 0px 2px;}
.FileTree li a:hover {background: #BDF;color:#000;}
.directory {background:url(images/directory.png) left top no-repeat;}/*文件夹图标*/
.directory-open {background:url(images/folder_open.png) left top no-repeat;}/*文件夹打开*/
.wait {background:url(images/spinner.gif) left top no-repeat;}/*等待图标*/
.Tree_txt {background:url(images/txt.png) left top no-repeat;}/*文本文件图标*/
.Tree_rar {background:url(images/ico.png) left top no-repeat;}
.Tree_zip {background:url(images/ico.png) left top no-repeat;}
/* File Extensions*/
.Tree_3gp {background:url(images/film.png) left top no-repeat; }
.Tree_afp {background:url(images/code.png) left top no-repeat; }
.Tree_afpa {background:url(images/code.png) left top no-repeat; }
.Tree_asp {background:url(images/code.png) left top no-repeat; }
.Tree_aspx {background:url(images/code.png) left top no-repeat; }
.Tree_avi {background:url(images/film.png) left top no-repeat; }
.Tree_bat {background:url(images/application.png) left top no-repeat; }
.Tree_bmp {background:url(images/picture.png) left top no-repeat; }
.Tree_c {background:url(images/code.png) left top no-repeat; }
.Tree_cfm {background:url(images/code.png) left top no-repeat; }
.Tree_cgi {background:url(images/code.png) left top no-repeat; }
.Tree_com {background:url(images/application.png) left top no-repeat; }
.Tree_cpp {background:url(images/code.png) left top no-repeat; }
.Tree_css {background:url(images/css.png) left top no-repeat; }
.Tree_doc {background:url(images/doc.png) left top no-repeat; }
.Tree_exe {background:url(images/application.png) left top no-repeat; }
.Tree_gif {background:url(images/picture.png) left top no-repeat; }
.Tree_fla {background:url(images/flash.png) left top no-repeat; }
.Tree_h {background:url(images/code.png) left top no-repeat; }
.Tree_htm {background:url(images/html.png) left top no-repeat; }
.Tree_html {background:url(images/html.png) left top no-repeat; }
.Tree_jar {background:url(images/java.png) left top no-repeat; }
.Tree_jpg {background:url(images/picture.png) left top no-repeat; }
.Tree_jpeg {background:url(images/picture.png) left top no-repeat; }
.Tree_js {background:url(images/script.png) left top no-repeat; }
.Tree_lasso {background:url(images/code.png) left top no-repeat; }
.Tree_log {background:url(images/txt.png) left top no-repeat; }
.Tree_m4p {background:url(images/music.png) left top no-repeat; }
.Tree_mov {background:url(images/film.png) left top no-repeat; }
.Tree_mp3 {background:url(images/music.png) left top no-repeat; }
.Tree_mp4 {background:url(images/film.png) left top no-repeat; }
.Tree_mpg {background:url(images/film.png) left top no-repeat; }
.Tree_mpeg {background:url(images/film.png) left top no-repeat; }
.Tree_ogg {background:url(images/music.png) left top no-repeat; }
.Tree_pcx {background:url(images/picture.png) left top no-repeat; }
.Tree_pdf {background:url(images/pdf.png) left top no-repeat; }
.Tree_php {background:url(images/php.png) left top no-repeat; }
.Tree_png {background:url(images/picture.png) left top no-repeat; }
.Tree_ppt {background:url(images/ppt.png) left top no-repeat; }
.Tree_psd {background:url(images/psd.png) left top no-repeat; }
.Tree_pl {background:url(images/script.png) left top no-repeat; }
.Tree_py {background:url(images/script.png) left top no-repeat; }
.Tree_rb {background:url(images/ruby.png) left top no-repeat; }
.Tree_rbx {background:url(images/ruby.png) left top no-repeat; }
.Tree_rhtml {background:url(images/ruby.png) left top no-repeat; }
.Tree_rpm {background:url(images/linux.png) left top no-repeat; }
.Tree_ruby {background:url(images/ruby.png) left top no-repeat; }
.Tree_sql {background:url(images/db.png) left top no-repeat; }
.Tree_swf {background:url(images/flash.png) left top no-repeat; }
.Tree_tif {background:url(images/picture.png) left top no-repeat; }
.Tree_tiff {background:url(images/picture.png) left top no-repeat; }
.Tree_txt {background:url(images/txt.png) left top no-repeat; }
.Tree_vb {background:url(images/code.png) left top no-repeat; }
.Tree_wav {background:url(images/music.png) left top no-repeat; }
.Tree_wmv {background:url(images/film.png) left top no-repeat; }
.Tree_xls {background:url(images/xls.png) left top no-repeat; }
.Tree_xml {background:url(images/code.png) left top no-repeat; }
.Tree_zip {background:url(images/zip.png) left top no-repeat; }
-->
</style>
</head>
<body>
<div class="area_tool L">
<!-- 左 -->
<div class="Tree_box L" id="fileTreeDemo_1">
</div><!-- //左 -->
</div>
</body>
</html>