留下 email,给你一个小例子。
解决方案 »
- 怎么使用JavaScript或者Jquery,给父窗口的一个input或者span绑定一个onclick事件?
- 用户按ENTER键就登陆
- 把指定文件另存为(已经有半成代码)
- 怎么实现页面部分加载提示效果(例如一个DIV内容加载提示效果)
- ff是不是不支持backgroundPositionY
- showModalDialog的问题
- 一个小问题.进来有奖哦
- 请问诸位大师,JavaScript 怎样 调用 ActiveX 控件,也就是说怎样和ActiveX 控件通信?
- 自己制作的换算器的问题.传不了值.请大侠帮帮忙.
- 微軟專家請進﹐innerHTML問題﹗
- 又是关于javascript的时间函数问题
- 有没有办法判断网页是否打开成功?
Email:[email protected]谢谢了
[email protected]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>树状菜单</title>
<!--在此处放入脚本程序-->
<script language ="javascript">
//定义基本变量
var itemTitle=new Array();
var itemContent=new Array();
var itemExpand=new Array();
var numItem=0;
var borderSize=0;
var expandId="expandDiv";
var layerWidth=300;
var layerIndent=1;
var layerHeight="<br>";
var layerColor="FFFFFF";
//浏览器判断
var ns4=(document.layers)?true:false;
var ie4=(document.all)?true:false;
//保存要加入的菜单项
function AddMenu(title,content){
itemTitle[numItem]=title;
itemContent[numItem]=content;
itemExpand[numItem]=0;
numItem++;
}
//换图片
function set_closeImage(url){
closeImage="<img src="+url+"border=0>";
}
//换图片
function set_openImage(url){
openImage="<img src="+url+"border=0>";
}
//缩进
function set_indent(indent){
layerIndent=indent;
}
function set_indent(height){
layerheight=height;
}
//创建菜单
function CreatMenu(width,height,left,top,border,bgcolor){
//设置显示风格属性
borderSize=border;
layerWidth=width;
layerColor=bgcolor;
outWidth=width+borderSize;
document.writeln ('<STYLE>');
document.write ('#expandDiv{position:absolute;left:'+left+';top:'+top+';width:'+width+';height:'+height+';}');
document.writeln('</STYLE>');
//创建菜单
document.writeln('<DIV ID="expandDiv">');
document.writeln('<table border=0 cellspacing=8 cellpadding='+borderSize+'width='+layerWidth+'><tr><td bgcolor=green>');
document.writeln('<table border=0 cellspacing=0 cellpadding=3 width=100% bgcolor='+layerColor+'><TR><TD>');
//二级菜单
for (i=0;i<numItem;i++){
document.writeln('<a href="JavaScript:toggle_expand('+i+') DispMenu()">'+closeImage+itemTitle[i]+'</a><BR>');
}
document.writeln('</TD></TR></TABLE></TD></TR></TABLE>');
document.writeln('</DIV>');
}
//显示二级菜单
function toggle_expand(num){
itemExpand[num]=itemExpand[num] ? 0:1;
}
//隐藏二级菜单
function DispMenu(){
var replaceText="";
replaceText+='<table border=0 cellspacing=8 cellpadding='+borderSize+'width='+layerWidth+'><TR><TD bgcolor = green>';
replaceText+='<table border=0 cellspacing=0 cellpadding=3 width=100% bgcolor='+layerColor+'><TR><TD>';
for(i=0;i<numItem;i++){
if (itemExpand[i]==1){
replaceText+="<a href=\"Javascript:toggle_expand("+i+");DispMenu()\">"+openImage+itemTitle[i]+"</a>"+layerHeight;
replaceText+="<table width="+layerWidth+"><tr><td>";
for(j=0;j<layerIndent;j++){
replaceText+=" ";
}
replaceText+="</td><td>";
replaceText+=itemContent[i]+"</td></tr></table>";
}
else{
replaceText+="<a href=\"JavaScript:toggle_expand("+i+") DispMenu()\">"+closeImage+itemTitle[i]+"</a><BR>";
}
}
replaceText+="</TD></TR></TABLE></TD></TR></TABLE>";
if(ns4){
var lyr=document.layers[expandId].document;
lyr.open();
lyr.writeln(replaceText);
lyr.close();
}
else{
//隐藏二级菜单
document.all[expandId].innerHTML=replaceText;
}
}
//加入菜单项内容
arrow="<img src=up.gif border=0>";
content=arrow+"<A href='jingguan/32-1.htm'target='mainFrame'>子菜单一</A><BR>"+arrow+"<A href='jinggua/j13.htm' target='mainFrame'>子菜单二</A><BR>"+arrow+"<A href='jingguan/j14.htm' target='mainFrame'>子菜单三</A<BR>"+arrow+"<A href='jingguan/j15.htm' target='mainFrame'>子菜单四</A><BR>";
AddMenu("父菜单一",content);
content=arrow+"<A href='jingguan/32-1.htm'target='mainFrame'>子菜单一</A><BR>"+arrow+"<A href='jinggua/j13.htm' target='mainFrame'>子菜单二</A><BR>"+arrow+"<A href='jingguan/j14.htm' target='mainFrame'>子菜单三</A<BR>"+arrow+"<A href='jingguan/j15.htm' target='mainFrame'>子菜单四</A><BR>";
AddMenu("父菜单二",content);
content=arrow+"<A href='jingguan/32-1.htm'target='mainFrame'>子菜单一</A><BR>"+arrow+"<A href='jinggua/j13.htm' target='mainFrame'>子菜单二</A><BR>"+arrow+"<A href='jingguan/j14.htm' target='mainFrame'>子菜单三</A<BR>"+arrow+"<A href='jingguan/j15.htm' target='mainFrame'>子菜单四</A><BR>";
AddMenu("父菜单三",content);
content=arrow+"<A href='jingguan/32-1.htm'target='mainFrame'>子菜单一</A><BR>"+arrow+"<A href='jinggua/j13.htm' target='mainFrame'>子菜单二</A><BR>"+arrow+"<A href='jingguan/j14.htm' target='mainFrame'>子菜单三</A<BR>"+arrow+"<A href='jingguan/j15.htm' target='mainFrame'>子菜单四</A><BR>";
AddMenu("父菜单四",content);
set_closeImage("close.gif");
set_openImage("open.gif");
</script>
<!--网页的显示风格-->
<style type="text/css">
<!--
body {font-family:"宋体";font-size:12px}
a:link {font-family:"宋体";font-size:12px;color:#000000;text-decoration:none}
a:hover {font-family:"宋体";font-size:12px;color:#FF0000;text-decoration:overline}
a:visited {font-family:"宋体";font-size:12px;color:#000000;text-decoration:none}
-->
</style>
</head><body leftmargin =0 topmargin =0 bgcolor ="#ffffff">
<!--调用函数-->
<script language ="javascript">
CreatMenu(320,250,0,0,0,"#FFffff")
</script>
</body></html>
[email protected]
<HTML>
<HEAD>
<TITLE> DSTree </TITLE>
<META NAME="Author" CONTENT="[email protected]" >
<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>
<base href="http://vip.5d.cn/star/dstree/" />
<script>
//code by star 20003-4-7
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 & 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>
<tr><td style="font:10px verdana;color:#999999" align=right>by <font color=#660000>sTar</font><br/> 2003-4-8</td></tr>
</table>
</BODY>
</HTML>
挺全的,我下了试了还是不错的!
http://www.yemaweb.com
JS的,ASP的,PHP的都有!哈哈
好好学习,天天向上!
我也要一份呀!
[email protected]
谢谢!
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>树状菜单</title>
<style>
<!--
#foldheader{cursor:hand;font-weight:normal;list-style-image:url(fold.GIF);; text-indent: -30px; list-style-type: none}
#foldheader1{cursor:hand;font-weight:normal;list-style-image:url(fold.GIF);; text-indent: -60px; list-style-type: none}
#foldheader2{cursor:hand;font-weight:normal;list-style-image:url(fold.GIF);; text-indent: -40px; list-style-type: none}
#foldinglist{list-style-image:url(list.GIF);; text-indent: -60px; list-style-type: none}
#foldinglist1{list-style-image:url(list.GIF);; text-indent: -90px; list-style-type: none}
//-->
</style>
<script language="JavaScript1.2">
<!--
/**
* Based on Folding Menu Tree
* Dynamic Drive (www.dynamicdrive.com)
* For full source code, installation instructions,
* 100's more DHTML scripts, and Terms Of
* Use, visit dynamicdrive.com
*
* Updated to support arbitrarily nested lists
* by Mark Quinn (@robocast.com) November 2nd 1998
*/
var head="display:''"
img1=new Image()
img1.src="fold.gif"
img2=new Image()
img2.src="open.gif"function change(){
if(!document.all)
returnif (event.srcElement.id=="foldheader"|| event.srcElement.id=="foldheader1"|| event.srcElement.id=="foldheader2") {
var srcIndex = event.srcElement.sourceIndex
var nested = document.all[srcIndex+1]
if (nested.style.display=="none") {
nested.style.display=''
event.srcElement.style.listStyleImage="url(open.gif)"
}
else {
nested.style.display="none"
event.srcElement.style.listStyleImage="url(fold.gif)"
}
}
}document.onclick=change//-->
</script>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../style.css" type="text/css">
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
margin-top: 0px;
}
.style2 {color: #000000}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head><body>
<div id="Layer1" style="position:absolute; width:200px; height:115px; z-index:1">
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<ul>
<li class="aa style2" id="foldheader">组织科</li>
<ul id="foldinglist" style="display:none; color: #000000;">
<li><a href="zgzc.asp" class="bb" target="_self">党建制度</a></li>
<ul id="foldinglist1" style="display:none">
<li class="aa"><a href="zgzc.asp" class="bb" >a栏</a></li>
<li class="aa"><a href="zgzc.asp" class="bb" target="_self">b栏</a></li>
<li class="aa"><a href="zgzc.asp" class="bb" target="_self">c栏</a></li>
<li class="aa"><a href="zgzc.asp" class="bb" target="_self">d栏</a></li>
</ul>
<li class="aa" id="foldheader1">创新成果</li>
<ul id="foldinglist1" style="display:none">
<li class="aa"><a href="zgzc.asp" class="bb" >a栏</a></li>
<li class="aa"><a href="zgzc.asp" class="bb" target="_self">立项选题活动</a></li>
<li class="aa"><a href="zgzc.asp" class="bb" target="_self">其它创新成果</a></li>
<li class="aa"><a href="zgzc.asp" class="bb" target="_self">d栏</a></li>
</ul>
<li class="aa" id="foldheader1">特色活动</li>
<ul id="foldinglist1" style="display:none">
<li class="aa"><a href="zgzc.asp" class="bb" >a栏</a></li>
<li class="aa"><a href="zgzc.asp" class="bb" target="_self">b栏</a></li>
<li class="aa"><a href="zgzc.asp" class="bb" target="_self">c栏</a></li>
<li class="aa"><a href="zgzc.asp" class="bb" target="_self">d栏</a></li>
</ul>
</ul>
<script language="JavaScript1.2">
<!--
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
// if cookie exists
if (offset != -1) {
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}if (get_cookie(window.location.pathname) != ''){
var openresults=get_cookie(window.location.pathname).split(" ")
for (i=0 ; i < openresults.length ; i++){
foldinglist[openresults[i]].style.display=''
document.all[foldinglist[openresults[i]].sourceIndex -
1].style.listStyleImage="url(list.gif)"
}
}if (document.all){
var nodelength=foldinglist.length-1
//var nodelenght2=foldinglist2.length-1var nodes=new Array(nodelength)
//var nodes2=new Array(nodelength2)
var openones=''
//var openones2=''
}function check(){
for (i=0 ; i <= nodelength ; i++){
if (foldinglist[i].style.display=='')
openones=openones + " " + i
}
document.cookie=window.location.pathname+"="+openones
}if (document.all)
document.body.onunload=check
//-->
</script>
</ul></td>
</tr>
</table>
</div>
<div align="left"></div>
</body>
</html>