我已经找到办法了,我使用的是xml加载tree
<?xml version="1.0" encoding="utf-8"?>
<nodes>
<node id="" text="用户管理">
<node id="" text="页面权限设置" url="privilegepageshow.aspx" target="ContentFrame" />
<node id="" text="帐号、权限管理" url="/manage/user_main.aspx" icon="user" target="ContentFrame" />
</node>
<node id="" text="<span style='font-family:宋体'>人员管理</span>">
<node id="" text="人员信息维护" url="紫色stand_main.aspx" target="ContentFrame" />
</node>
<node id="" text="<span style='color:red;'>修改密码</span>" url="changepass.aspx" icon="changepass" target="ContentFrame"/>
<node id="" text="安装系统组件" url="downloadocx.htm" icon="ocx" hint="使用本系统的打印功能需要安装此组件并且系统中要安装OfficeWord和OfficeExcel,此组件只需安装一次" target="ContentFrame"/>
<node id="" text="<span onclick='logout()'>注销</span>" icon="logout"/>
</nodes>
修改密码是红色的,点击注销是执行的自定义js函数
<?xml version="1.0" encoding="utf-8"?>
<nodes>
<node id="" text="用户管理">
<node id="" text="页面权限设置" url="privilegepageshow.aspx" target="ContentFrame" />
<node id="" text="帐号、权限管理" url="/manage/user_main.aspx" icon="user" target="ContentFrame" />
</node>
<node id="" text="<span style='font-family:宋体'>人员管理</span>">
<node id="" text="人员信息维护" url="紫色stand_main.aspx" target="ContentFrame" />
</node>
<node id="" text="<span style='color:red;'>修改密码</span>" url="changepass.aspx" icon="changepass" target="ContentFrame"/>
<node id="" text="安装系统组件" url="downloadocx.htm" icon="ocx" hint="使用本系统的打印功能需要安装此组件并且系统中要安装OfficeWord和OfficeExcel,此组件只需安装一次" target="ContentFrame"/>
<node id="" text="<span onclick='logout()'>注销</span>" icon="logout"/>
</nodes>
修改密码是红色的,点击注销是执行的自定义js函数
tree.onclick = function(e)
{
alert(e.target.text);
e.target.expand();
}
不过按照你的思路,这么可以
alert(tree.selectedNode.id+":"+tree.selectedNode.text);