当前位置: 首页 > 工具软件 > DHTML Tree > 使用案例 >

dhtml 界面UI (tree)

饶德本
2023-12-01

1.xml的部分代码(可以使用<userdata>传递url)

<item text="Books" id="books" open="1" call="1" select="1">
  <item text="Mystery !!! &amp; Thrillers" id="mystery" open="1">
   <item text="Bestsellers" id="bsthrillers" >
    <item text="Lawrence Block" id="lb">
     <userdata name="system">true</userdata>
    </item>

 

 

2.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
  <title>Changing iconsets</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta name="title" content="Samples" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <link rel="icon" href="../common/favicon.ico" type="image/x-icon" />
  <link rel="shortcut icon" href="../common/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" href="../common/css/style.css" type="text/css" media="screen" />
 </head>
 <body>
    <link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxtree.css">
 <script  src="../../codebase/dhtmlxcommon.js"></script>
 <script  src="../../codebase/dhtmlxtree.js"></script>

 <table width="20%" style="float:left">
  <tr>
   <td valign="top">
    <div id="treeboxbox_tree0" style="width:100%; height:318px;border :1px solid Silver;"></div><br>

   </td>
  </tr>
  <tr>
   <td>&nbsp;</td>
  </tr>
 </table>
 <table style="width:80%;float:left;" border="1">
  <tr><td>
    <iframe name="right" src="" frameborder="1" width="100%" height="500"></iframe>
   </td>
  </tr>
 </table>
 
 <script>
   tree=new dhtmlXTreeObject("treeboxbox_tree0","100%","100%",0);

   tree.setSkin('dhx_skyblue');
   tree.setImagePath("../../codebase/imgs/");
   tree.setOnClickHandler(tonclick);//添加event
   tree.loadXML("tree_b.xml");
   
   function tonclick(id) {   //不用管id,我也不明白
       alert("Item " + tree.getItemText(id) + " was selected"+tree.getUserData(id,"system"));
      // window.frames["right"].location="10_tree_iconset.html"; //点击树形菜单,iframe会产生新页面

       window.frames["right"].location=tree.getUserData(id,"system");
   };
 </script>
   
 </body>
</html>

 类似资料: