日期:2014-05-16  浏览次数:20379 次

求助:Firefox或NS6的浏览器不能兼容树形菜单。
如题,在IE里面可以正常使用,可用其它浏览器就不能正常使用。代码如下:

<html>
<head>
<link rel="stylesheet" href="stylesheet/styles_general.css">
<style>
<!--
#foldheader{cursor:pointer;cursor:hand ; font-weight:bold ;
list-style-image:url(fold.gif)}
#foldinglist{list-style-image:url(list.gif)}
//-->
</style>
<script language="JavaScript1.2">
<!--

//Smart Folding Menu tree- By Dynamic Drive (rewritten 03/03/02)
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var head="display:''"
img1=new Image()
img1.src="fold.gif"
img2=new Image()
img2.src="open.gif"

var ns6=document.getElementById&&!document.all
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1

function checkcontained(e){
var iscontained=0
cur=ns6? e.target : event.srcElement
i=0
if (cur.id=="foldheader")
iscontained=1
else
while (ns6&&cur.parentNode||(ie4&&cur.parentElement)){
if (cur.id=="foldheader"||cur.id=="foldinglist"){
iscontained=(cur.id=="foldheader")? 1 : 0
break
}
cur=ns6? cur.parentNode : cur.parentElement
}

if (iscontained){
var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
if (foldercontent.style.display=="none"){
foldercontent.style.display=""
cur.style.listStyleImage="url(open.gif)"
}
else{
foldercontent.style.display="none"
cur.style.listStyleImage="url(fold.gif)"
}
}
}

if (ie4||ns6)

document.onclick=checkcontained

//-->
</script>
<title></title>
</head>
<body >
<li class=LI><a href="indexx.asp" target="_parent">Main</a></li>
  <li class=LI id=foldheader>Folder</li>"
  <ul class=UL id='foldinglist' style='display:none' style=&{head};>
<li class="LI"><a href='' target='rightFrame'>menu1</a></li><br>
  <li class="LI"><a href='' target='rightFrame'>menu2</a></li><br>
</ul>
  <li class="LI"><a href="Logoff.asp" target="rightFrame">Log Out</a></li>
</body>
</html>

请帮忙!谢谢!


------解决方案--------------------
这边测试 ff 可以跑