有两个JS的鼠标特效
一个是使鼠标放在特定区域就会出现详细信息
一个是对鼠标右键的定制
两个同时出现在一帧里就只能显示后一个
如果在代码里把右键的特效注释掉
那就可以显示第一个的特效
这是第一个的代码:
<% for(int i=0;i<20;i++)
{%>
用户<%=i%> <%=i%>
| ' ">
<%}%>
这是第二个的代码:
复制代码到head
复制代码到body
这就是菜单定制部分
第二个的JS程序:
function checkDom()
{
this.name=navigator.appName.toLowerCase()
this.ver=navigator.appVersion.toLowerCase()
this.opera=(this.name=="opera")?1:0
this.dom=(document.getElementById&&!this.opera)?1:0
this.ie=(document.all)?1:0
this.ie6=(this.dom&&this.ie&&this.ver.indexOf('msie 6'))?1:0
this.ie5=(this.dom&&this.ie&&!this.ie6)?1:0
this.ns4=(document.layers)?1:0
this.ns6=(this.dom&&!this.ie)?1:0
this.ns=(this.ns4||this.ns6)?1:0
this.bw=(this.dom||this.ie||this.ns||this.opera)?1:0
}
bw = new checkDom()
function getPageSize()
{
this.x = document.getElementsByTagName('html').item(0).clientWidth||document.getElementsByTagName('html').item(0).offsetWidth||document.body.offsetWidth||innerWidth
this.y = document.getElementsByTagName('html').item(0).clientHeight||document.getElementsByTagName('html').item(0).offsetHeight||document.body.offsetHeight||innerHeight
this.x2 = parseInt(this.x/2)||0
this.y2 = parseInt(this.y/2)||0
this.sx = document.body.scrollWidth||0
this.sy = document.body.scrollHeight||0
}
var pg
function pgScrollAt()
{
this.x = document.getElementsByTagName('html').item(0).scrollLeft||document.body.scrollLeft||(bw.ns6?pageXOffset:0)||0
this.y = document.getElementsByTagName('html').item(0).scrollTop||document.body.scrollTop||(bw.ns6?pageYOffset:0)||0
}
function getCoords(e)
{
if(bw.ie) e = event
this.x = e.clientX
this.y = e.clientY
}
function makeDom(name)
{
if(!document.getElementById) return null
this.name = name
this.evnt = document.getElementById(name)
this.css = this.evnt.style
this.x = this.css.pixelLeft || this.evnt.offsetLeft
this.y = this.css.pixelTop || this.evnt.offsetTop
this.w = this.css.pixelWidth || this.evnt.offsetWidth
this.h = this.css.pixelHeight || this.evnt.offsetHeight
makeDom.prototype.moveTo = function(x,y)
{
x = parseInt(x); y = parseInt(y)
this.css.left = x+'px'
this.css.top = y+'px'
this.x = x
this.y = y
}
makeDom.prototype.show = function()
{
this.css.visibility = 'visible'
}
makeDom.prototype.hide = function()
{
this.css.visibility = 'hidden'
}
makeDom.prototype.clipTo = function(t,r,b,l,sW)
{
this.cT = t; this.cR = r; this.cB = b; this.cL = l
a = arguments
for(k in a) a[k] = a[k]>=0 ? a[k]+'px' : a[k]
this.css.clip = 'rect('+t+','+r+','+b+','+l+')'
if(sW) this.css.width=r
}
}
function showContMenu(e)
{
ms = new getCoords(e)
cX = ms.x+aContMenu.w
cY = ms.y+aContMenu.h sc = new pgScrollAt()
aContMenu.moveTo(cX+sc.x,cY+sc.y)
aContMenu.show()
cDirX = cX==ms.x ? 1:0
cDirY = cY==ms.y ? 1:0
doClip(cDirX,cDirY)
return false
}
cM = 0
function doClip(dirX,dirY)
{
if(cM<100)
{
cT=cR=cB=cL='auto'
if(dirX) cR = cM+'%'
else cL = (100-cM)+'%'
if(dirY) cB = cM+'%'
else cT = (100-cM)+'%'
aContMenu.clipTo(cT,cR,cB,cL)
cM+=40
setTimeout('doClip('+dirX+','+dirY+')',35)
}
else
{
aContMenu.clipTo('auto','auto','auto','auto')
cM = 0
}
}
function initContMenu(e)
{
if(bw.dom)
{
pg = new getPageSize()
aContMenu = new makeDom('contMenu')
isLoaded = 1
}
}
onload = initContMenu
document.oncontextmenu=showContMenu
document.onclick=new Function('aContMenu.hide()')
哪位高手能解决啊??
快 啊!!!
谢谢了!!!^_^