<p class="sycode"> <br> </p> <title>Flywe の Blog - Ajax 另类二级联动菜单(DIV+CSS)</title> <br> <script language="javascript"> <br /> var req = null; <br /> if(window.XMLHttpRequest) { <br /> try { <br /> req = new XMLHttpRequest(); <br /> } catch(e) { <br /> req = false; <br /> } <br /> // branch for IE/Windows ActiveX version <br /> } else if(window.ActiveXObject) { <br /> try { <br /> req = new ActiveXObject("Msxml2.XMLHTTP"); <br /> } catch(e) { <br /> try { <br /> req = new ActiveXObject("Microsoft.XMLHTTP"); <br /> } catch(e) { <br /> req = false; <br /> } <br /> } <br /> } <br /> <br /> var node; <br /> function OnClickCate(What,CateID) <br /> { <br /> if(What == null) return <br /> node = document.getElementById("RssCate" + CateID) <br /> node = node.nextSibling <br /> while(node && node.tagName && node.tagName != "DIV") <br /> { <br /> node = node.nextSibling <br /> } <br /> if(node == null) return <br /> var initDisplay = node.style.display; <br /> var RssDIV = document.getElementsByTagName("DIV"); <br /> if(RssDIV != null) <br /> { <br /> for(var i = 0;i<RssDIV.length;i++) <br /> { <br /> if(RssDIV[i].className == "RssDIV") <br /> RssDIV[i].style.display = "none"; <br /> } <br /> } <br /> if(document.getElementById("RssCate" + CateID).getAttribute("status") != "ok") <br /> { <br /> if(req) <br /> { <br /> var str = null; <br /> node.innerHTML = "正在装载数据……"; <br /> node.style.display="block"; <br /> surl ='cs/menulist.asp?id='+CateID+'&cDate='+ new Date().getTime(); <br /> req.open('GET', surl, true); <br /> req.onreadystatechange = alerttest; <br /> req.send(null); <br /> } <br /> document.getElementById('RssCate'+CateID).setAttribute('status','ok'); <br /> } <br /> else <br /> { <br /> node.style.display=(initDisplay == "block"?"none":"block"); <br /> } <br /> //node = null; <br /> } <br /> function alerttest() <br /> { <br /> if (req.readyState == 4) <br /> { <br /> if (req.status == 200) <br /> { <br /> node.innerHTML = req.responseText; <br /> } <br /> <br /> } <br /> } <br /> </script> <br> <br> <style type="text/css">.CateDIV { <br /> BORDER-RIGHT: #808080 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #ffffff 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 9pt; PADDING-BOTTOM: 2px; BORDER-LEFT: #ffffff 1px solid; WIDTH: 300px; CURSOR: pointer; COLOR: #000000; PADDING-TOP: 3px; BORDER-BOTTOM: #808080 1px solid; HEIGHT: 22px; BACKGROUND-COLOR: #ddeeff; TEXT-ALIGN: left <br /> } <br /> .RssDIV { <br /> PADDING-RIGHT: 2px; DISPLAY: none; PADDING-LEFT: 2px; FONT-SIZE: 9pt; PADDING-BOTTOM: 2px; PADDING-TOP: 2px; BACKGROUND-COLOR: transparent <br /> } <br /> A { <br /> FONT-SIZE: 9pt; COLOR: #000099; TEXT-DECORATION: none <br /> } <br /> A:visited { <br /> COLOR: red <br /> } <br /> A:active { <br /> COLOR: red <br /> } <br /> A:hover { <br /> COLOR: #0000ff <br /> } <br /> </style> <br> <br> <meta content="MSHTML 6.00.3790.1830" name="GENERATOR"> <br>