<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script src="jquery-1.11.2.min.js"></script> <style type="text/css"> *{ margin:0px auto; padding:0px} #wai{ 800px;} .list{ 100%; height:35px; background-color:#09F; margin-top:2px; color:white; font-weight:bold; text-align:left; line-height:35px; vertical-align:middle; font-size:28px; padding:5px} .mulu{ background-color:#FC9} .mulu:hover{ cursor:pointer} body { background-color: #FFF; } body,td,th { color: #D6D6D6; } </style> </head> <body> <br /> <div id="wai"> <?php session_start(); $filename=""; if(!empty($_SESSION["lujing"])) { $filename = $_SESSION["lujing"]; $sj = dirname($_SESSION["lujing"]);//找上级目录,使用session存上级目录的值 echo "<div id='prev' class='list' lj='{$sj}'>返回上一层</div>"; } else { $filename = ""; } ?> <div id="nr"> <?php //打开该文件夹 $dir = opendir($filename); while($f = readdir($dir)) { if($f!="." && $f!="..") { $ml = $filename."/".$f; if(is_file($filename."/".$f)) { echo "<div class='list'>{$f}</div>";//显示的是文件 } else { echo "<div lj='{$ml}' class='list mulu'>{$f}</div>";//显示的是文件夹 } } } closedir($dir);//关闭文件 ?> </div> </div> <script type="text/javascript"> //向下一层的点击事件 $(".mulu").dblclick(function(){ var lj = $(this).attr("lj"); $.ajax({ url:"chulii.php", data:{lj:lj}, type:"POST", dataType:"TEXT", success: function(){ window.location.href="test1.php"; } }); }) //返回上一层的点击事件 $("#prev").dblclick(function(){ var lj = $(this).attr("lj"); $.ajax({ url:"chulii.php", data:{lj:lj}, type:"POST", dataType:"TEXT", success: function(){ window.location.href="test1.php"; } }); }) </script> </body>
处理页面:
<?php session_start(); $lj = $_POST["lj"]; $_SESSION["lujing"] = $lj;
显示的页面: