上一篇:我有2个类似的js,不知道有用否 1 >>
我搜集过一段类似的js,不知道有用否
第一步:把如下代码加入<head>区域中
<SCRIPT LANGUAGE="JavaScript">
<!--
var bV=parseInt(navigator.appVersion);
var NS4=(document.layers) ? true : false;
var IE4=((document.all)&&(bV>=4))?true:false;
var ver4 = (NS4 || IE4) ? true : false;
function expandIt(){return}
function expandAll(){return}
function nomsg(){self.status="";}
if(ver4){
document.write("<SCR"+"IPT LANGUAGE=\"JavaScript\" SRC=\"rsmenu.js\"></SCR"+"I
PT>");
}
//-->
</SCRIPT>
第二步:把如下代码加入<body>区域中
<span class="label"></span><br>
<!---------- begin OUTLINE ----------->
<!--上方全部展开/关闭-->
<A HREF="#" onClick="expandAll(false); return false"><IMG NAME="imEx" SRC="bulle
t-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展开或关闭全部菜单"><FONT STYLE="font-
size: 9pt">展开/关闭全部</FONT></A>
<!-- <BLOCKQUOTE> -->
<!--第一级父菜单-->
<DIV ID="elOneParent" CLASS=parent style="margin-left: 0.1px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
<A HREF="#" style="color:#FFFF00; text-decoration:none;" onClick="expandIt(@#elO
ne@#); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDE
R=0 ALT="展开全部菜单"> 主菜单一
</a></td></tr></table>
</DIV>
<!--第一级子菜单-->
<DIV ID="elOneChild" CLASS=child style="margin-left: 0.5px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
<tr><td>
<A HREF="1.htm" target="data">连接页面1</A><BR>
</td></tr><tr><td>
<A HREF="2.htm" target="data">连接页面2</A><BR>
</td></tr><tr><td>
<A HREF="3.htm" target="data">连接页面3</A><BR>
</td></tr><tr>
<td height="12"> <A HREF="4.htm" target="data">连接页面4</A> </td>
</tr></table>
</DIV>
<!--第二级父菜单-->
<DIV ID="elTwoParent" CLASS=parent style="margin-left: 0.1px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
<A HREF="#" style="color:#FFFF00; text-decoration:none;" onClick="expandIt(@#elT
wo@#); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDE
R=0 ALT="展开全部菜单"> 主菜单二
</a></td></tr></table>
</DIV>
<!--第二级子菜单-->
<DIV ID="elTwoChild" CLASS=child style="margin-left: 0.5px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
<tr><td>
<A HREF="1.htm" target="data">连接页面1</A><BR>
</td></tr><tr><td>
<A HREF="2.htm" target="data">连接页面2</A><BR>
</td></tr><tr><td>
<A HREF="3.htm" target="data">连接页面3</A><BR>
</td></tr><tr><td>
<A HREF="4.htm" target="data">连接页面4</A>
</td></tr></table>
</DIV>
<!--第三级父菜单-->
<DIV ID="elThreeParent" CLASS=parent style="margin-left: 0.1px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
<A HREF="#" style="color:#FFFF00; text-decoration:none;" onClick="expandIt(@#elT
hree@#); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BOR
DER=0 ALT="展开全部菜单"> 主菜单三
</a></td></tr></table>
</DIV>
<!--第三级子菜单-->
<DIV ID="elThreeChild" CLASS=child style="margin-left: 0.5px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
<tr><td>
<A HREF="1.htm" target="data">连接页面1</A><BR>
</td></tr><tr><td>
<A HREF="2.htm" target="data">连接页面2</A><BR>
</td></tr><tr><td>
<A HREF="3.htm" target="data">连接页面3</A><BR>
</td></tr><tr><td>
<A HREF="4.htm" target="data">连接页面4</A>
</td></tr></table>
</DIV>
<!--第四级父菜单-->
<DIV ID="elFourParent" CLASS=parent style="margin-left: 0.1px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
<A HREF="#" style="color:#FFFF00; text-decoration:none;" onClick="expandIt(@#elF
our@#); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORD
ER=0 ALT="展开全部菜单"> 主菜单四
</a></td></tr></table>
</DIV>
<!--第四级子菜单-->
<DIV ID="elFourChild" CLASS=child style="margin-left: 0.5px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
<tr><td>
<A HREF="1.htm" target="data">连接页面1</A><BR>
</td></tr><tr><td>
<A HREF="2.htm" target="data">连接页面2</A><BR>
</td></tr><tr><td>
<A HREF="3.htm" target="data">连接页面3</A><BR>
</td></tr><tr><td>
<A HREF="4.htm" target="data">连接页面4</A>
</td></tr></table>
</DIV>
<!--第五级父菜单-->
<DIV ID="elFiveParent" CLASS=parent style="margin-left: 0.1px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
<A HREF="#" style="color:#FFFF00; text-decoration:none;" onClick="expandIt(@#elF
ive@#); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORD
ER=0 ALT="展开全部菜单"> 主菜单五
</a></td></tr></table>
</DIV>
<!--第五级子菜单-->
<DIV ID="elFiveChild" CLASS=child style="margin-left: 0.5px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
<tr><td>
<A HREF="1.htm" target="data">连接页面1</A><BR>
</td></tr><tr><td>
<A HREF="2.htm" target="data">连接页面2</A><BR>
</td></tr><tr><td>
<A HREF="3.htm" target="data">连接页面3</A><BR>
</td></tr><tr><td>
<A HREF="4.htm" target="data">连接页面4</A>
</td></tr></table>
</DIV>
<!--第六级父菜单-->
<DIV ID="elSixParent" CLASS=parent style="margin-left: 0.1px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
<A HREF="#" style="color:#FFFF00; text-decoration:none;" onClick="expandIt(@#elS
ix@#); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDE
R=0 ALT="展开全部菜单"> 主菜单六
</a></td></tr></table>
</DIV>
<!--第六级子菜单-->
<DIV ID="elSixChild" CLASS=child style="margin-left: 0.5px">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
<tr><td>
<A HREF="1.htm" target="data">连接页面1</A><BR>
</td></tr><tr><td>
<A HREF="2.htm" target="data">连接页面2</A><BR>
</td></tr><tr><td>
<A HREF="3.htm" target="data">连接页面3</A><BR>
</td></tr><tr><td>
<A HREF="4.htm" target="data">连接页面4</A>
</td></tr></table>
</DIV>
<!-- </BLOCKQUOTE> -->
<!--下方全部展开/关闭-->
<DIV ID="elExpParent" CLASS=regular> <A HREF="#" onClick="expandAll(true); retur
n false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展
开/关闭全部">展开/关闭全部</A> </DIV>
<!---------- end OUTLINE ----------->
<br>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
if(NS4){
firstEl = "elOneParent";
firstInd = getIndex(firstEl);
showAll();
arrange();
}
//-->
</SCRIPT>
rsment.js
isExpanded = false;
function getIndex(el) {
ind = null;
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id == el) {
ind = i;
break;
}
}
return ind;
}
function arrange() {
nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.
height;
for (i=firstInd+1; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.visibility != "hide") {
whichEl.pageY = nextY;
nextY += whichEl.document.height;
}
}
}
function initIt(){
if (NS4) {
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
}
arrange();
}
else {
tempColl = document.all.tags("DIV");
for (i=0; i<tempColl.length; i++) {
if (tempColl(i).className == "child") tempColl(i).style.display = "none";
}
}
}
function expandIt(el) {
if (!ver4) return;
if (IE4) {expandIE(el)} else {expandNS(el)}
}
function expandIE(el) {
whichEl = eval(el + "Child");
whichIm = event.srcElement;
if (whichEl.style.display == "none") {
whichEl.style.display = "block";
whichIm.src = "bullet-minus.gif";
}
else {
whichEl.style.display = "none";
whichIm.src = "bullet-plus.gif";
}
}
function expandNS(el) {
whichEl = eval("document." + el + "Child");
whichIm = eval("document." + el + "Parent.document.images[@#imEx@#]");
if (whichEl.visibility == "hide") {
whichEl.visibility = "show";
whichIm.src = "bullet-minus.gif";
}
else {
whichEl.visibility = "hide";
whichIm.src = "bullet-plus.gif";
}
arrange();
}
function showAll() {
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
whichEl.visibility = "show";
}
}
function expandAll(isBot) {
newSrc = (isExpanded) ? "bullet-plus.gif" : "bullet-minus.gif";
if (NS4) {
document.images["imEx"].src = newSrc;
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Parent") != -1) {
whichEl.document.images["imEx"].src = newSrc;
}
if (whichEl.id.indexOf("Child") != -1) {
whichEl.visibility = (isExpanded) ? "hide" : "show";
}
}
arrange();
if (isBot && isExpanded) scrollTo(0,document.layers[firstInd].pageY);
}
else {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
if (divColl(i).className == "child") {
divColl(i).style.display = (isExpanded) ? "none" : "block";
}
}
imColl = document.images.item("imEx");
for (i=0; i<imColl.length; i++) {
imColl(i).src = newSrc;
}
}
isExpanded = !isExpanded;
}
with (document) {
write("<STYLE TYPE=@#text/css@#>");
if (NS4) {
write(".parent {position:absolute; visibility:hidden}");
write(".child {position:absolute; visibility:hidden}");
write(".regular {position:absolute; visibility:hidden}")
}
else {
write(".child {display:none}")
}
write("</STYLE>");
}
onload = initIt;
下一篇:form文本域的通用校验函数 >>
相关文章:
- · 罗亭的可输入下拉框的解密简化版.
- · IE里的探索之浏览器概览
- · IE里的探索之向标准上下文相关菜单里添加条目
- · IE里的探索之添加浏览器栏
- · IE里的探索之添加工具条按钮(2)
- · IE里的探索之添加工具条按钮(1)
- · IE里的探索之创建具有良好行为的自定义元素
- · IE里的探索之定制浏览器好助手(上1)
- · IE里的探索之定制浏览器好助手(上2)
- · IE里的探索之定制浏览器好助手(中1)
- · IE里的探索之定制浏览器好助手(下)
- · IE里的探索(想定制自己的IE的可以看一看)
- · 这个object还有其他几种用法.现在贴了给大家.
- · 自动关闭窗口,方法总结
- · 这个脚本可以使你方便得获得各网站的连接速度
- · 列表框操作函数集合
- · 常用javascript函数(一)
- · 控制输出字符串的长度,可以区别中英文
- · 常用javascript函数(二)
- · 如何判断客户端浏览器的脚本js.vbs功能是否被禁止,通过隐藏域实现
- · 台湾的两篇文章,看看也好:唯讀的表單文字輸入項
- · Creating CSS Buttons (一)
- · Creating CSS Buttons (二)
- · 用javascript实现浮点数的截取小数位数,并四舍五入
- · three trim function(javascript)
- · 用ASP将javascript代码写入客户端执行的一种简易方法。。。
- · Trim Function in javascript
- · java分页源码
- · 过滤表格中的链接(用javascript提取表格中的数据)
- · 来看看哟.一个天气预报的小偷.可以偷到每天更新的全国24小时城市天气预报.
- · 一个把WORD转换成HTML的程序
- · 饮水思源,我从这里学到的知识投入应用,现在再奉献回给大家(可编辑页面的部分属性)
- · 用 WSH 想ASP 一样 查询数据库!(WSH 学习心得2)
- · 一段窗口自动关闭的源代码,不受js打开的限制,与大家共享!
- · 带进度条的关闭窗口,绝对有用!并可根据需要改写。
- · 一组javascript绘图函数
- · 限制只能中文输入的方法。(详细讲解,对象初学者)
- · 一般的页面滚动条是在右边的,想让他在左边吗:)
