请问如何给XML标签加上超链接

loop2000 2006-03-02 01:50:52
如下代码,我想在"网络类"和"10"上分别加上超链接http://www.sina.com.cn和http://www.21cn.com
当点击"网络类"后打开www.sina.com.cn,当点击"10"的时候打开www.21cn.com
<html>
<head>
<title>Gene Ontology Tree View</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="windows-Target" content="_top">
<link rel="stylesheet" href="css/go.css" type="text/css">
<style>
#treeBox .ec{margin:0 0 0 2;}
#treeBox .hasItems{font-weight:bold;height:24px;padding:0 2 0 0;margin:1px;cursor:hand;color:#555555;border:1px solid #fffffa;}
#treeBox .Items{height:24px;padding:0 2 0 0;margin:1px;cursor:hand;color:#555555;border:1px solid #fffffa;}
</style>
<script>
var HC = "color:#990000;border:1px solid #cccccc";
var SC = "background-color:#efefef;border:1px solid #cccccc;color:#000000;";
var IO = null;
function initTree()
{
var rootn = document.all.menuXML.documentElement;
var sd = 0;
document.onselectstart = function(){return false;}
document.all.treeBox.appendChild(createTree(rootn,sd));
}
function createTree(thisn,sd)
{
var nodeObj = document.createElement("span");
var upobj = document.createElement("span");
with(upobj)
{
style.marginLeft = sd*20;
className = thisn.hasChildNodes()?"hasItems":"Items";
innerHTML = "<img src=image/Lminus.png class=ec>" + thisn.getAttribute("text") +"";
onmouseup = function()
{
if(event.button != 1) return;
if(this.getAttribute("cn"))
{
this.setAttribute("open",!this.getAttribute("open"));
this.cn.style.display = this.getAttribute("open")?"inline":"none";
this.all.tags("img")[0].src = this.getAttribute("open")?"image/Lminus.png":"image/Lplus.png";
}
if(IO)
{
IO.runtimeStyle.cssText = "";
IO.setAttribute("selected",false);
}
IO = this;
this.setAttribute("selected",true);
this.runtimeStyle.cssText = SC;
}
onmouseover = function()
{
if(this.getAttribute("selected"))return;
this.runtimeStyle.cssText = HC;
}
onmouseout = function()
{
if(this.getAttribute("selected"))return;
this.runtimeStyle.cssText = "";
}
}
nodeObj.appendChild(upobj);
nodeObj.insertAdjacentHTML("beforeEnd","<br>")
if(thisn.getAttribute("href") != null){
upobj.setAttribute("href",thisn.getAttribute("href"));
}
if(thisn.hasChildNodes())
{
var i;
var nodes = thisn.childNodes;
var cn = document.createElement("span");
upobj.setAttribute("cn",cn);
if(thisn.getAttribute("open") != null)
{
upobj.setAttribute("open",(thisn.getAttribute("open")=="true"));
upobj.getAttribute("cn").style.display = upobj.getAttribute("open")?"inline":"none";
if( !upobj.getAttribute("open"))upobj.all.tags("img")[0].src ="image/Lplus.png";
}
for(i=0;i<nodes.length;cn.appendChild(createTree(nodes[i++],sd+1)));
nodeObj.appendChild(cn);
}
else
{
upobj.all.tags("img")[0].src ="image/file.png";
}
return nodeObj;
}
</script>

</head>
<body>
<table width=1004 cellspacing=0 cellpadding=0>
<tr height=80>
<td> </td>
</tr>
</table>

<xml id=menuXML>
<?xml version="1.0" encoding="GB2312"?>
<TreeRoot text="计算机图书" open="true" url1='http://www.sina.com.cn' url2='http://www.163.com'>

<myTree text='网络类  10' open='false'>
<myTree text='数据库  20' open='false' />
<myTree text='C语言   30' open='false' />

</myTree>
</TreeRoot>
</xml>
<script>window.onload = initTree;</script>
<table>
<tr><td id=treeBox style="width:1004px;height:200px;border:1px solid #cccccc;padding:5 3 3 5;" valign=top>
</td></tr>
</table>
</body>
</html>

...全文
266 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
loop2000 2006-03-05
  • 打赏
  • 举报
回复
UP
孟子E章 2006-03-05
  • 打赏
  • 举报
回复
没看明白什么意思。
加链接可以在xsl里做,也可以用XMLDOM实现

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧