阅读:4343回复:2
求助:IE中可以显示的树型结构怎么改成支持火狐的?
在改一个程序,树型结构在IE下能正常显示,但在火狐下不能用,已经知道问题是document.all不支持FF,但是不知道怎么改,麻烦大哥大姐们帮我看看,附有源代码,谢谢各位!!!
急用! <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <STYLE>.TreePoint { BACKGROUND-POSITION: left 0%; BACKGROUND-IMAGE: url('img/point.gif'); WIDTH: 22px; BACKGROUND-REPEAT: repeat-y } .TreeBgColor { BACKGROUND-COLOR: #f1f1f1 } .TreeSign { WIDTH: 22px; CURSOR: hand } .ExplainON { FONT-SIZE: 9pt; MARGIN: 10%; CURSOR: hand; COLOR: #000000; FONT-FAMILY: Arial; WHITE-SPACE: nowrap; BACKGROUND-COLOR: #ffffff; TEXT-DECORATION: none } .ExplainOFF { FONT-SIZE: 9pt; MARGIN: 10%; CURSOR: hand; COLOR: #000000; FONT-FAMILY: Arial; WHITE-SPACE: nowrap; TEXT-DECORATION: none } .style1 { FONT-SIZE: 12px } </STYLE> <script language="javascript" src="/javascript/winopen/winopen.js"></script> <META content="Microsoft FrontPage 4.0" name=GENERATOR></HEAD> <BODY bgColor=#f1f1f1> <SCRIPT> var TreeImg = new Array(); TreeImg[0] = new Image(); TreeImg[1] = new Image(); TreeImg[2] = new Image(); TreeImg[0].src = "/images/NodeImg2.gif"; TreeImg[1].src = "/images/NodeImg1.gif"; TreeImg[2].src = "/images/NodeImg0.gif"; function MakeTree(newObj,oldObj,explain,num,title) { if(num==0) { pointClass = ""; } if(num==1) { pointClass = "TreePoint"; } if(title&&title!="") { title = ' title="'+title+'" ' } else { title = "" } var word = '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="TreeBgColor">'; word+= '<tr height=20>'; word+= '<td class="TreeSign">'; word+= '<img border="0" src="'+TreeImg[1].src+'" id="sign_'+newObj+'" onclick="SiblingClick()">' word+= '</td>'; word+= '<td>' word+= '<span class="ExplainOFF" onclick="TreeControl(this.value)" value="'+newObj+'" '+title+' ><nobr>'+explain+'</nobr></span>'; word+= '</td>'; word+= '</tr>'; word+= '<tr style="display: none" id="'+newObj+'" height=20>'; word+= '<td class="'+pointClass+'"> </td> '; word+= '<td valign="top" width="70" id="td_'+newObj+'"></td>'; word+= '</tr>'; word+= '</table>'; eval(oldObj+".innerHTML+='"+ word +"'"); word = null; } function MakeLine(newObj,oldObj,explain,url,ltarget,title) { var the_target = ""; if(ltarget&<arget!="") { the_target += 'target="'+ltarget+'"'; } if(title&&title!="") { title = ' title="'+title+'" ' } else { title = "" } var word = '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="TreeBgColor">'; word+= '<tr height=20>'; word+= '<td class="TreeSign">'; word+= '<a href="'+url+'" '+the_target+' ><img border="0" src="'+TreeImg[2].src+'"></a>' word+= '</td>'; word+= '<td>' word+= '<a href="'+url+'" '+the_target+title+' ><span class="ExplainOFF" onclick="LineControl(this.value)"><nobr>'+explain+'</nobr></span></a>'; word+= '</td>'; word+= '</tr>'; word+= '</table>'; eval(oldObj+".innerHTML+='"+ word +"'"); word = null; } //--------- 建立 菜单 框架 对象 ----------// function GoodTree(objName) { this.id = "tree_"+objName; this.obj = objName; this.length = 0; this.addTree = addTree; this.addLine = addLine; this.addEndTree = addEndTree; this.endTree = endTree; document.body.innerHTML += '<div id="stage_'+this.id+'" style="display: none"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="TreeBgColor"><tr><td id="td_'+this.id+'"></td></tr></table></div>'; } function SubTree(objName,objID) { this.obj = objName; this.id = objID; this.addTree = addTree; this.addLine = addLine; this.addEndTree = addEndTree; this.length = 0; } //---------- 菜单 方法 addTree ------------// function addTree(explain,title) { var subID = this.id + "_" + this.length; var subObj = this.obj+"["+this.length+"]"; var oldID = "td_"+ this.id; eval(subObj+"= new SubTree('"+subObj+"','"+subID+"')"); MakeTree(subID,oldID,explain,1,title); this.length++; } function addEndTree(explain,title) { var subID = this.id + "_" + this.length; var subObj = this.obj+"["+this.length+"]"; var oldID = "td_"+ this.id; eval(subObj+"= new SubTree('"+subObj+"','"+subID+"')"); MakeTree(subID,oldID,explain,0,title); this.length++; } function addLine(explain,url,target,title) { var subID = this.id + "_" + this.length; var oldID = "td_"+ this.id; MakeLine(subID,oldID,explain,url,target,title); this.length++; } //--------- 完成 菜单 和 消去 变量和 源蓝图 并且输出 -------------// function endTree(place) { var the_stage = eval("stage_"+ this.id); var obj = eval(place); obj.innerHTML += the_stage.innerHTML; document.getElementById("stage_"+ this.id).outerHTML =""; eval(this.obj+"=null"); } //-----------菜单的 隐藏 和显示 ------------// var temp_tree_index = null; //纪录点击的TD的 sourceIndex function TreeControl(obj) { var tr_obj = eval(obj); var sign_obj = eval("sign_"+obj); if(temp_tree_index) { document.all(temp_tree_index).className = "ExplainOFF" } event.srcElement.className = "ExplainON"; temp_tree_index = event.srcElement.sourceIndex; if(tr_obj.style.display=="none") { tr_obj.style.display = "block"; sign_obj.src = TreeImg[0].src; return; } if(tr_obj.style.display=="block") { tr_obj.style.display = "none"; sign_obj.src = TreeImg[1].src; return; } } function LineControl() { if(temp_tree_index) { document.all(temp_tree_index).className = "ExplainOFF" } event.srcElement.className = "ExplainON"; temp_tree_index = event.srcElement.sourceIndex; } function SiblingClick() { event.srcElement.parentElement.nextSibling.firstChild.click(); } var One = new GoodTree("One"); One.addTree("客户化设置","客户化设置"); One[0].addTree("客户档案管理设置","客户档案管理设置"); One[0][0].addLine("客户I级分类设置","../config/file/firstKind.jsp","mainFrame","客户I级分类设置"); One[0][0].addLine("客户II级分类设置","../config/file/secondKind.jsp","mainFrame","客户II级分类设置"); One[0][0].addLine("客户III级分类设置","../config/file/thirdKind.jsp","mainFrame","客户III级分类设置"); One[0][0].addLine("客户类型设置","../config/file/fieldType.jsp","mainFrame","客户类型设置"); One[0][0].addLine("客户优质级别","../config/file/strategyClass.jsp","mainFrame","客户优质级别"); One[0][0].addLine("回款延期报警设置","../config/file/gatherPeriodExpiry.jsp","mainFrame","回款延期报警设置"); One[0][0].addLine("欠款报警设置","../config/file/gatherSumLimit.jsp","mainFrame","欠款报警设置"); One[0][0].addLine("联络超期报警设置","../config/file/contactPeriodExpiry.jsp","mainFrame","联络超期报警设置"); One[0].addTree("客户联络管理设置","客户联络管理设置"); One[0][1].addLine("联络理由设置","../config/contact/reason.jsp","mainFrame","联络理由设置"); One[0].addTree("客户发票管理设置","客户发票管理设置"); One[0][2].addLine("发票类型设置","../config/invoice/invoiceType.jsp","mainFrame","发票类型设置"); One[0].addTree("销售管理设置","销售管理设置"); One[0][3].addLine("产品订单销售绩效比例设置","../config/intranalyse/rate_locate.jsp","mainFrame","产品订单销售绩效比例设置"); One[0][3].addLine("产品零售绩效比例设置","../config/intranalyse/retailRate_locate.jsp","mainFrame","产品零售绩效比例设置"); One[0][3].addLine("订单销售价格折扣设置","../config/sale_credit/orderRate_locate.jsp","mainFrame","订单销售价格折扣设置"); One[0][3].addLine("零售价格折扣设置","../config/sale_credit/retailRate_locate.jsp","mainFrame","零售价格折扣设置"); One[0][3].addLine("赊货转订单价格折扣设置","../config/sale_credit/creditRate_locate.jsp","mainFrame","赊货转订单价格折扣设置"); One[0].addTree("报警督办管理设置","报警督办管理设置"); One[0][4].addLine("I级报警设置","../config/alarm/firstAlarm.jsp","mainFrame","I级报警设置"); One[0][4].addLine("II级报警设置","../config/alarm/secondAlarm.jsp","mainFrame","II级报警设置"); One[0][4].addLine("III级报警设置","../config/alarm/thirdAlarm.jsp","mainFrame","III级报警设置"); One[0].addTree("其他设置","其他设置"); One[0][5].addLine("关键字查询设置","../config/key/key.jsp","mainFrame","关键字查询设置"); One.addTree("客户档案管理","客户档案管理"); One[1].addLine("客户档案登记","../file/register.jsp","mainFrame","客户档案登记"); One[1].addLine("客户档案登记复核","../file/check_list.jsp","mainFrame","客户档案登记复核"); One[1].addLine("客户档案查询","../file/query_locate.jsp","mainFrame","客户档案查询"); One[1].addLine("客户档案变更","../file/change_locate.jsp","mainFrame","客户档案变更"); One[1].addTree("客户档案删除管理","客户档案删除管理"); One[1][4].addLine("客户档案删除","../file/delete/delete_locate.jsp","mainFrame","客户档案删除"); One[1][4].addLine("档案删除恢复","../file/delete/recovery_locate.jsp","mainFrame","档案删除恢复"); One[1][4].addLine("客户档案永久删除","../file/delete/realDelete_list.jsp","mainFrame","客户档案永久删除"); One.addTree("客户联络管理","客户联络管理"); One[2].addLine("产品售后查询","../contact/serviceQuery_key_locate.jsp","mainFrame","产品售后查询"); One[2].addLine("客户联络登记","../contact/register_list.jsp","mainFrame","客户联络登记"); One[2].addLine("客户联络登记复核","../contact/check_list.jsp","mainFrame","客户联络登记复核"); One[2].addLine("客户联络查询","../contact/query_locate.jsp","mainFrame","客户联络查询"); One[2].addLine("客户询价支持","../../design/price_change/query_locate.jsp","mainFrame","客户询价支持"); One.addTree("销售人员管理","销售人员管理"); One[3].addLine("销售人员查询","../sales_manager/salesManagerQuery_locate.jsp","mainFrame","销售人员查询"); One[3].addLine("销售人员工作权限变更","../sales_manager/change_locate.jsp","mainFrame","销售人员工作权限变更"); One.addTree("销售日志管理","销售日志管理"); One[4].addLine("销售日志登记","../sales_daily_work/register.jsp","mainFrame","销售日志登记"); One[4].addLine("销售日志查询","../sales_daily_work/query_locate.jsp","mainFrame","销售日志查询"); One.endTree("document.body"); </SCRIPT> </BODY></HTML> |
|
1楼#
发布于:2006-08-20 12:10
唉~ 看着就晕了
不过即使用getElementsByTagName替换all也依然不能在火狐中展开 不知道关键又在何处呢。。。 |
|
2楼#
发布于:2006-08-20 12:10
前几天遇到一个style="display:none"的按钮,在firefox中居然还能显示出来,见鬼。当时也没深究,估计有可能是样式表的支持有问题。所以使用这个也得小心了。。。
|
|