把这个写成一个类吧TREEVIEW
//JAVASCRIPT树型菜单源码----------------------
<script language=JavaScript1.2>
scores = new Array(20);
var numTotal=0;
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;
if (ver4) {
with (document) {
write("<STYLE TYPE='text/css'>");
if (NS4) {
write(".parent {position:absolute; visibility:visible}");
write(".child {position:absolute; visibility:visible}");
write(".regular {position:absolute; visibility:visible}")
}
else {
write(".child {display:none}")
}
write("</STYLE>");
}
}
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 (!ver4) return;
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 {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
whichEl = divColl(i);
if (whichEl.className == "child") whichEl.style.display = "none";
}
}
}
function expandIt(el) {
if (!ver4) return;
if (IE4) {
whichEl1 = eval(el + "Child");
for(i=1;i<=numTotal;i++){
whichEl = eval(scores[i] + "Child");
if(whichEl!=whichEl1) {
whichEl.style.display = "none";
}
}
whichEl1 = eval(el + "Child");
if (whichEl1.style.display == "none") {
whichEl1.style.display = "block";
}
else {
whichEl1.style.display = "none";
}
}
else {
whichEl = eval("document." + el + "Child");
for(i=1;i<=numTotal;i++){
whichEl = eval("document." + scores[i] + "Child");
if(whichEl!=whichEl1) {
whichEl.visibility = "hide";
}
}
if (whichEl.visibility == "hide") {
whichEl.visibility = "show";
}
else {
whichEl.visibility = "hide";
}
arrange();
}
}
onload = initIt;
</script>
//----------------------------------------调用
<div id=KB1Parent>
<a onClick="expandIt('KB1');return false" href="#"><img src="plus.gif" border=0>精品下载</a>
</div>
<div class=child id=KB1Child>
<a href="#"><img src="blank.gif" border=0>Dreamweaver 资源</a><br>
<a href="#"><img src="blank.gif" border=0>Fireworks 资源</a><br>
<a href="#"><img src="blank.gif" border=0>Flash 资源</a><br>
<a href="#"><img src="blank.gif" border=0>Photoshop 资源</a>
</div>
<div id=KB2Parent>
<a onClick="expandIt('KB2');return false" href="#"><img src="plus.gif" border=0>免费申请</a>
</div>
<div class=child id=KB2Child>
<a href="#"><img src="blank.gif" border=0>免费计数器申请</a><br>
<a href="#"><img src="blank.gif" border=0>免费留言板申请</a><br>
<a href="#"><img src="blank.gif" border=0>免费网上调查申请</a></div>
<div id=KB3Parent>
<a onClick="expandIt('KB3');return false" href="#"><img src="plus.gif" border=0>酷站源码</a>
</div>
<div class=child id=KB3Child>
<a href="#"><img src="blank.gif" border=0>脚本收集</a><br>
<a href="#"><img src="blank.gif" border=0>HTML特效</a><br>
<a href="#"><img src="blank.gif" border=0>ASP源程序下载</a><br>
<a href="#"><img src="blank.gif" border=0>XML方面</a><br>
</div>
<script>numTotal=3;scores[1]='KB1';scores[2]='KB2';scores[3]='KB3';</script>
//------------------------------------------------------------
制作要点:
1、每一个分类都需定义值:
<div id=KB1Parent> // ID值为唯一的
<a onClick="expandIt('KB1'); return false" href="#" >精品下载</a></div> // 定义onclick属性
--------------------------------------------------------------------------------
2、每一个分类下面的文件都需统一定义class及ID。
<div class=child id=KB1Child> // ID值为唯一的
<a href="#" >Dreamweaver 资源</div>
<a href="#" >Dreamweaver 资源</div>
</div>
--------------------------------------------------------------------------------
3、在分类的下边有一 script 的定义:
<script>numTotal=3;scores[1]='KB1';scores[2]='KB2';scores[3]='KB3';</script>
如果要增加一个类,则需把 numTotal 增加数值,再加一个scores[N]='KBN',例:
<script>numTotal=4;scores[1]='KB1';scores[2]='KB2';scores[3]='KB3';scores[4]='KB4';</script>
转载于:https://www.cnblogs.com/lkcn/archive/2004/10/12/51243.html
把这个写成一个类吧TREEVIEW相关推荐
- 转载几篇别人写的皮肤类控件的技术文章
转载几篇别人写的皮肤类控件的技术文章 原连接:http://blog.sina.com.cn/s/blog_4c3538470100ezhu.html 实现控件的透明背景 很多情况下,我们需要控件 的 ...
- 如何把前端项目写成一座屎山?
作者:阿佛加德奔 原文:https://juejin.cn/post/7086735198942920712 前言 最近几年前端发展的非常快,SPA的繁荣让前端的工程化也越来越重.在很多场景下,前端的 ...
- Controller类的方法上的RequestMapping一定要写在Controller类里吗?
使用Spring Cloud做项目的同学会使用Feign这个组件进行远程服务的调用,Feign这个组件采用模板的方式,有着优雅的代码书写规范.核心原理对Feign等相关注解进行解析,并提取信息,在Sp ...
- 写一个ArrayList类的动态代理类
动态代理可以提供对另一个对象的访问,同时隐藏实际对象的具体事实,代理对象对客户隐藏了实际对象.动态代理可以对请求进行其他的一些处理,在不允许直接访问某些类,或需要对访问做一些特殊处理等,这时候可以考虑 ...
- Day14作业 三、编程题 写一个Student类,属性:名字,年龄,分数,班级 (注意分包)
三.编程题 写一个Student类,属性:名字,年龄,分数,班级 (注意分包) 写一个测试类:创建一个集合,里面装6个学生(有三个班级class01,class02,class03) 例如:list. ...
- php 编写mysql,自己写的MySQL类
自己写的MySQL类 ---------- php debug ---------- Server=localhost;DataBase=mysql;UserID=root;PassWord=1234 ...
- C# 写的棋牌类游戏(全源码)。
C# 写的棋牌类游戏(全源码) http://d.namipan.com/d/b47c1bb0ed558e95c85313ba845e57ddad98b70568aa6704 有兴趣的开发者可以下载看 ...
- T5 根据派生类写出基类(Java) (10分)
6-1 根据派生类写出基类(Java) (10分) 裁判测试程序样例中展示的是一段定义基类People.派生类Student以及测试两个类的相关Java代码,其中缺失了部分代码,请补充完整,以保证测试 ...
- PTA 6-2 根据派生类写出基类(Java)
6-2 根据派生类写出基类(Java) 裁判测试程序样例中展示的是一段定义基类People.派生类Student以及测试两个类的相关Java代码,其中缺失了部分代码,请补充完整,以保证测试程序正常运行 ...
最新文章
- 服务器系统linux怎么安装教程,CentOS 8.0.1905 linux服务器系统安装与配置图解教程...
- C ++中线程的简单示例
- HandlerSocket client for java——hs4j正式发布0.1版本
- Java Review - 并发编程_伪共享
- why carbon 13?
- vscode解决java无法输入(scanner)问题
- 面向对象编程,链式调用,先输出‘hello’,10秒之后,输出‘world’
- lib和dll的区别、生成以及使用详解
- php与go服务之间调用,PHP调用Go服务的正确方式 - Unix Domain Sockets
- Protobuf3教程
- Quotations
- 转 Mac 使用ab性能测试工具
- 物化视图(materialized view) 实现数据迁移、数据定时同步
- ES5 对象的扩展(Object.preventExtensions)、密封(Object.seal)和冻结(Object.freeze)
- 【目标跟踪】基于matlab背景差分多目标捕捉【含Matlab源码 810期】
- mysql 优化器 cost评估_MySQL优化器cost计算
- ASP.NET ASHX 一般处理程序教程
- 计算机二级excel经典操作题,计算机二级office经典题库
- windows录屏_Windows电脑录屏制作gif神器
- 计算机论文参考文献范文,计算机文类论文参考文献 计算机文参考文献有哪些...