帝国CMS进入开源时代
 帝国论坛技术交流区网络编程请问这个树形菜单的超链接怎么做? 【本版专题贴子】  
22G硬防帝国空间1G100元/5G280元
帝国CMS模板下载中心
测试:生成20万数据共用107分钟
《帝国下载系统》全面免费
帝国备份王2008版发布
1G双线帝国空间+200M数据库=158
站长工具 - dotool.cn
广告联系QQ:627174919
主题:请问这个树形菜单的超链接怎么做? [加入收藏夹]   

coyisoso
用户头衔:书生

精华贴   :0
发贴数   :60
经验值   :247
注册时间:2006-06-27
信息 搜索 好友 发送悄悄话 《帝国网站管理系统》基础教程下载】   [第 1 楼]
请问这个树形菜单的超链接怎么做?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> DSTree </TITLE>
<META>
<style>
body,td{font:12px verdana}
#treeBox{background-color:#fffffa;}
#treeBox .ec{margin:0 5 0 5;}
#treeBox .hasItems{font-weight:bold;height:20px;padding:3 6 0 6;margin:2px;cursor:hand;color:#555555;border:1px solid #fffffa;}
#treeBox .Items{height:20px;padding:3 6 0 6;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*10;
                className = thisn.hasChildNodes()?"hasItems":"Items";
                innerHTML = "<img src=expand.gif class=ec>" + thisn.getAttribute("text") +"";
               
                onmousedown = 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")?"expand.gif":"contract.gif";
                        }
                        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 = "";
                }
                oncontextmenu = contextMenuHandle;
                onclick = clickHandle;
        }

        if(thisn.getAttribute("treeId") != null){
                upobj.setAttribute("treeId",thisn.getAttribute("treeId"));
        }
        if(thisn.getAttribute("href") != null){
                upobj.setAttribute("href",thisn.getAttribute("href"));
        }
        if(thisn.getAttribute("target") != null){
                upobj.setAttribute("target",thisn.getAttribute("target"));
        }

        nodeObj.appendChild(upobj);
        nodeObj.insertAdjacentHTML("beforeEnd","<br>")

        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 ="contract.gif";
                }
               
                for(i=0;i<nodes.length;cn.appendChild(createTree(nodes[i++],sd+1)));
                nodeObj.appendChild(cn);
        }
        else{
                upobj.all.tags("img")[0].src ="endnode.gif";
        }
        return nodeObj;
}
window.onload = initTree;
</script>

<script>
function clickHandle(){
        // your code here
}
function contextMenuHandle(){
        event.returnValue = false;
        var treeId = this.getAttribute("treeId");
        // your code here
}
</script>
</HEAD>
<BODY>
<xml id=menuXML>
<?xml version="1.0" encoding="GB2312"?>
<DSTreeRoot text="根节点" open="true" href="http://" treeId="123">
       
        <DSTree text="技术论坛" open="false" treeId="">
                <DSTree text="5DMedia" open="false" href="http://" target="box" treeId="12">
                        <DSTree text="网页编码" href="http://" target="box" treeId="4353" />
                        <DSTree text="手绘" href="http://" target="box" treeId="543543" />
                        <DSTree text="灌水" href="http://" target="box" treeId="543543" />
                </DSTree>
                <DSTree text="BlueIdea" open="false" href="http://" target="box" treeId="213">
                        <DSTree text="DreamWeaver &amp; JS" href="http://" target="box" treeId="4353" />
                        <DSTree text="FlashActionScript" href="http://" target="box" treeId="543543" />
                </DSTree>
                <DSTree text="CSDN" open="false" href="http://" target="box" treeId="432">
                        <DSTree text="JS" href="http://" target="box" treeId="4353" />
                        <DSTree text="XML" href="http://" target="box" treeId="543543" />
                </DSTree>
        </DSTree>

        <DSTree text="资源站点" open="false" treeId="">
                <DSTree text="素材屋" href="http://" target="box" treeId="12" />
                <DSTree text="桌面城市" open="false" href="http://" target="box" treeId="213">
                        <DSTree text="壁纸" href="http://" target="box" treeId="4353" />
                        <DSTree text="字体" href="http://" target="box" treeId="543543" />
                </DSTree>
                <DSTree text="MSDN" open="false" href="http://" target="box" treeId="432">
                        <DSTree text="DHTML" href="http://" target="box" treeId="4353" />
                        <DSTree text="HTC" href="http://" target="box" treeId="543543" />
                        <DSTree text="XML" href="" target="box" treeId="2312" />
                </DSTree>
        </DSTree>

</DSTreeRoot>
</xml>
<table style="position:absolute;left:100;top:100;">
<tr><td id=treeBox style="width:400px;height:200px;border:1px solid #cccccc;padding:5 3 3 5;" valign=top></td></tr>
</table>
</BODY>
</HTML>



为了创作,可以放弃一切!
2006-07-04 16:30:48 已设置保密 顶部 回复 引用 报告 编辑 删除

wm_chief
用户头衔:管理员

精华贴   :21
发贴数   :47816
经验值   :109097
注册时间:2002-10-30
信息 搜索 好友 发送悄悄话 《帝国网站管理系统》零基础实例入门教程】   [第 2 楼]

href="http://
是这个吧



[零基础入门教程] [模板制作教程] [采集使用教程]
2006-07-05 10:09:35 已设置保密 顶部 回复 引用 报告 编辑 删除

快速回复
内容

表情
使用EBB代码 使用smile代码 显示签名 自动分析url 自动分析img
     【进入高级模式】   (按 Ctrl+Enter 直接提交)
    顶部  加入收藏夹
关于帝国 | 广告服务 | 联系我们 | 法律声明 | 隐私条款 | 许可协议
Powered by: EBB Version 2.2.1