浮动的X-menu

news/2024/5/18 12:29:21 标签: JavaScript, ASP.net, Microsoft, ASP, BBS

<script>
function CoolMenuControl(){

file://-----常规变量---

this.lastScrollX=0;
this.lastScrollY=0;
this.lastScrollW=0;
this.lastScrollH=0;
this.FlsY=0;
this.td_X=0;
this.td_Y=0;
this.td_W=0;
this.td_H=0;
this.td=0;
this.My=14;
this.mouseon=0;
this.current=null
this.hk_name;
this.hktable_name;
this.menudiv_name;
this.menutable_name;
this.menuname;
this.ml=0;
this.menuarray=new Array();
this.speed;
this.href="";

file://-----菜单项目---
function menuitem(type,value,url,target){
this.type=type
this.value=value
this.url=url
this.target=target
}

file://-----插入菜单---
this.insertmenu=function(type,value,url,target){
this.menuarray[this.menuarray.length]=new menuitem(type,value,url,target)
}

file://-----程序初试化---
this.init=function(name,bdc,bgc,speed,Alpha){
var inhtml=""
var cellcount=0
var lastcellcount=0
this.menuname=name
this.hk_name=name+"hk"
this.hktable_name=name+"hktable"
this.menudiv_name=name+"menudiv"
this.menutable_name=name+"menutable"
this.speed=speed

for (i=0;i<this.menuarray.length;i++)
{
if (this.menuarray[i].type=="2") cellcount=cellcount+1
if (this.menuarray[i].type=="1" || this.menuarray[i].type=="0") {cellcount=0}
if (lastcellcount<cellcount) {lastcellcount++}

}

file://alert(cellcount)


stylecode="cursor:hand;filter:Alpha(style=0,opacity="+Alpha+");background-color:"+bgc

suspendcode="<DIV id="+this.hk_name+" style='POSITION:absolute;z-index:3' οnclick='"+name+".doClick()'>"
+"<table id="+this.hktable_name+" border='1' width='0' cellspacing='0' style='border-collapse: collapse' bordercolor='"+bdc+"'>"
+"<tr><td height='18' style='"+stylecode+"'></td></tr></table></div>";
document.write(suspendcode);

var fcell=true
for (i=0;i<this.menuarray.length;i++)
{
switch(this.menuarray[i].type)
{
case "0":
t=cellcount*2
if (t<=0)
{
inhtml+='<tr><td colspan=2 class=ht οnmοuseοver=\''+name+'.href="'+this.menuarray[i].url+','+this.menuarray[i].target+'"\'>'+this.menuarray[i].value
}
else
{
inhtml+='<tr><td colspan='+t+' class=ht οnmοuseοver=\''+name+'.href="'+this.menuarray[i].url+','+this.menuarray[i].target+'"\'>'+this.menuarray[i].value
}
fcell=true
break;
case "1":
t=(cellcount-1)*2
if (t<=0)
{
inhtml+='<tr><td width=6><td οnmοuseοver=\''+name+'.href="'+this.menuarray[i].url+','+this.menuarray[i].target+'"\'>'+this.menuarray[i].value
}
else
{
inhtml+='<tr><td width=6><td colspan='+t+' οnmοuseοver=\''+name+'.href="'+this.menuarray[i].url+','+this.menuarray[i].target+'"\'>'+this.menuarray[i].value
}
fcell=true
break;

case "2":
if (fcell)
{
inhtml+='<tr><td width=6><td οnmοuseοver=\''+name+'.href="'+this.menuarray[i].url+','+this.menuarray[i].target+'"\'>'+this.menuarray[i].value;
fcell=false
}
else
{
inhtml+='<td width=6><td οnmοuseοver=\''+name+'.href="'+this.menuarray[i].url+','+this.menuarray[i].target+'"\'>'+this.menuarray[i].value;
}
break;
}
}
inhtml='<div id='+this.menudiv_name+' οnmοusemοve="'+name+'.doOver()" style="right:12px;POSITION:absolute;TOP:12px;z-index:2">'
+'<table id='+this.menutable_name+' border="0" cellpadding="2" class="menu" cellspacing="4">'
+inhtml
+'</table></div>';
file://alert(inhtml)
document.write(inhtml);

this.lastScrollX=0;
this.lastScrollY=-4;
this.posXY(eval(this.menutable_name).cells[0])
this.td_W=eval(this.menutable_name).cells[0].scrollWidth+6
this.td_H=eval(this.menutable_name).cells[0].scrollHeight
setInterval(name+".scrollback()",1)
}

file://-----单击超连接---
this.doClick=function(){
file://alert(this.url)
var url=this.href.split(",")
file://alert(url[0])
file://alert(url[1])
if (url[0]=="") return

if (url[1]=="_blank")
{window.open(url[0])}
else
{location.href=url[0]}
}

file://-----滑动处理---
this.scrollback=function(){
FY=document.body.scrollTop;
diffX=this.td_X-3
diffY=this.My
diffW=this.td_W
diffH=this.td_H

percentX=this.speed*(diffX-this.lastScrollX);
percentY=this.speed*(diffY-this.lastScrollY);
percentW=this.speed*(diffW-this.lastScrollW);
percentH=this.speed*(diffH-this.lastScrollH);
percent=.1*(FY-this.FlsY);

if(percentX>0)percentX=Math.ceil(percentX);
else percentX=Math.floor(percentX);
if(percentY>0)percentY=Math.ceil(percentY);
else percentY=Math.floor(percentY);
if(percentW>0)percentW=Math.ceil(percentW);
else percentW=Math.floor(percentW);
if(percentH>0)percentH=Math.ceil(percentH);
else percentH=Math.floor(percentH);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);

eval(this.hk_name).style.pixelTop+=percentY+percent;
eval(this.hk_name).style.pixelLeft+=percentX;
eval(this.hktable_name).style.pixelWidth+=percentW;
eval(this.hktable_name).style.pixelHeight+=percentH;
eval(this.menudiv_name).style.pixelTop+=percent;


this.lastScrollX=this.lastScrollX+percentX;
this.lastScrollY=this.lastScrollY+percentY;
this.lastScrollW=this.lastScrollW+percentW;
this.lastScrollH=this.lastScrollH+percentH;
this.FlsY=this.FlsY+percent;
}

file://-----滑出---
this.doOver=function() {
if (event.srcElement.tagName=="TD") {
if (event.srcElement.innerText.length==0 || event.srcElement.innerText=="|") return
this.posXY(event.srcElement)
this.td_W=event.srcElement.scrollWidth+6
this.td_H=event.srcElement.scrollHeight
this.My=this.td_Y-5-document.body.scrollTop
}
}

file://-----绝对定位---
this.posXY=function(obj){
hk_left=obj.offsetLeft
hk_top=obj.offsetTop
vParent = obj.offsetParent;

while (vParent.tagName.toUpperCase() != "BODY")
{
hk_left += vParent.offsetLeft;
hk_top += vParent.offsetTop;
vParent = vParent.offsetParent;
}

this.td_X=hk_left
this.td_Y=hk_top
}

file://-----关于---
this.about=function(){
alert("OK")
}

}
</script>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<style>
.b{color=#000066;cursor:hand}
.menu {
font-family:Arial;
cursor:Default;
font-size:12px;
border:1px #000000 solid;
border-collapse: collapse;
filter:progid:DXImageTransform.Microsoft.Gradient(gradienttype=0, startcolorstr=#ffffff, endcolorstr=#dddddd)
progid:DXImageTransform.Microsoft.Shadow(direction=135,color=#cccccc,strength=3);
}
.ht{
font-weight:bold
}
</style>
<!--
第一步:实体化X-Menu类
用法:
var <实体变量>.new CoolMenuControl()
--->
<script language="javascript">
var CoolMenu3=new CoolMenuControl()

var about=new Array()
about[0]="关于X-Menu菜单\n\nAuthor:PuterJam\nCopyright 2004\n转载请通知本人"
about[1]="关于作者\n\n\"这家伙很懒,什么也没留下!!\"\n不过欢迎大家和我交流Javascript\nQQ:10644570\nE-Mail:PuterJam@etang.com"

</script>
</head>
<body>
<!--
第二步:建立菜单项目---

用法:
<实体变量>.insertmenu(类型,Html代码,链接网址,目标)
 类型:0代表菜单标题,1代表树型菜单子项目,2代表横向菜单子项目
 Html代码:显示在菜单上的Html代码
链接网址:不用多说了,网址或Javascript脚本
目标:默认为空,既不在本页打开;"_blank"代表在新的页面打开
 例如:
CoolMenu2.insertmenu("2","<img src=http://www.blueidea.com/img/icon/arrow.gif> 新浪网","http://www.sina.com.cn/","_blank")  
-->
<script>

CoolMenu3.insertmenu("0","<img src=http://bbs.dvbbs.net/Skins/Default/nofollow.gif> 树形菜单","","")
CoolMenu3.insertmenu("0","<img src=http://www.blueidea.com/img/common/logo.gif> ","http://www.blueidea.com/","_blank")
CoolMenu3.insertmenu("1","关于X-Menu菜单","javascript:alert(about[0])","")
CoolMenu3.insertmenu("1","关于作者","javascript:alert(about[1])","")
CoolMenu3.insertmenu("1","联系我","mailto:PuterJam@etang.com","")
CoolMenu3.insertmenu("1","你的浏览器版本","javascript:alert(navigator.appName)","")
</script>

<!--
第三步:建立菜单---

用法:
<实体变量>.init(实体变量名,边框颜色,背景颜色,滑动速度,背景半透明度)
'实体变量名'必须与<实体变量>相同
如果背景颜色="transparent"既为完全透明
 例如:
CoolMenu1.init("CoolMenu1","#002000","#38FFff",0.1,15)  
-->
<script>CoolMenu3.init("CoolMenu3","#002000","#f0FF00",0.3,25)</script>
<script>
for (i=0;i<=100;i++)
{
document.write(i+"<br>")
}
</script>

</body>
download.gif点击下载此文件

转自 http://www.imting.com/puterjam/blogview.asp?logID=3&cateID=1


http://www.niftyadmin.cn/n/608992.html

相关文章

List、Set和Map详解及其区别和他们分别适用的场景

Java中的集合包括三大类 它们是Set&#xff08;集&#xff09;、List&#xff08;列表&#xff09;和Map&#xff08;映射&#xff09;&#xff0c;它们都处于java.util包中&#xff0c;Set、List和Map都是接口&#xff0c;它们有各自的实现类。Set的实现类主要有HashSet和Tre…

经典答案:下水道井盖为什么是圆的——让面试官无语

经典答案&#xff1a;下水道井盖为什么是圆的——让面试官无语面试官&#xff1a;现在我们要问一个问题&#xff0c;看看你的创造性思维能力。不要想得太多&#xff0c;运用日常生活中的常识&#xff0c;描述一下你的想法。这个问题是&#xff0c;下水道的井盖为什么是圆的&…

离线环境安装Docker,运行tomcat,部署项目war包

离线环境安装Docker&#xff0c;运行tomcat&#xff0c;部署项目war包 1.Centos7.5离线环境安装docker 2.运行tomcat镜像 3.部署项目war包

腾讯QQ/TM珊瑚虫外挂/集成安装版(v3.0.2)[下载]

最新版本&#xff1a; 腾讯 QQ/TM 珊瑚虫外挂v3.0.2 http://orienthomebj.link263.com/soff/CoralQQ.rar腾讯 QQ/TM 珊瑚虫集成安装版v3.0.2 &#xff08;QQ2004II 正式版&#xff09;http://orienthomebj.link263.com/soff/IPQQ2004II.exe≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡…

改善程序员脑力的70条方法

最近在网上看到的,供大家分享 1. 深呼吸&#xff1a;让更多的空气&#xff08;氧气&#xff09;进入血液和大脑。同时深呼吸也可以放松自己。 2. 冥思&#xff1a;简单的冥思方法就是闭上双眼&#xff0c;将思绪专注在呼吸上&#xff0c;收缩肌肉然后再放松身体。走神后&#…

Java IO流操作(III)——File类案例一:输出制定目录下所有java文件名(包含子目录)案例二:删除指定的目录(包含子目录)

1. File常用的构造 File file new File("字符串路径");File f new File("D:\\a\\b.txt"); File file new File("父路径的字符串表现形式","子路径的字符串表现形式");File f2 new File("D:\\a","b.txt"); Fil…

指定namespace的pod调度到固定node

添加指定namespace的pod可以调度到固定node的功能 为了增强项目间的安全隔离。 目前rancher不支持此功能&#xff0c;k8s原生具备此功能&#xff0c;评估是否可以作为企业级使用 参考openshift的实现&#xff0c; 支持了集群、项目、开发者级别的 node-selector.

名人侃考研搞笑版

痞子蔡&#xff1a;如果我有一千万&#xff0c;我就不考研。我有一千万吗&#xff1f;没有。所以我仍然要考研。   苏永康&#xff1a;站在社会和校园的两端&#xff0c;一样的为难&#xff0c;惟一的答案&#xff0c;没钱自费考研真的好难&#xff01;   …