首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

求教onmouseover事件,该怎么处理

2012-02-07 
求教onmouseover事件我在图片上加了几个热点,想让鼠标ommouseover这几个热点的时候分别弹出不同的div(若是

求教onmouseover事件
我在图片上加了几个热点,   想让鼠标ommouseover这几个热点的时候分别弹出不同的div(若是div里能加入图片就更好了),   onmouseout后div就消失.

除此以外,   如何能让这个网页躲开ie7的javascript屏蔽,   而且能用在firefox上?   因为如果默认的屏蔽打开了,   用户就看不到这些效果,   我的热点也就白做了.

请高手赐教,   有礼了!

[解决办法]
写两个方法
showDiv() 中以 Div.style.display = "inline ";显示Div

HiddenDiv() 中以 Div.style.display = "none ";隐藏Div


ommouseover= "showDiv() "
ommouseout = "HiddenDiv() "
[解决办法]
<html>
<head> <meta http-equiv= "Content-Type " content= "text/html;charset=gb2312 ">
<title> show and hide </title>
</head>
<script>
function ShowDiv(){
test.style.top=event.clientY-2;
test.style.left=event.clientX+3;
test.style.visibility= "visible ";
}
function HiddenDiv(){
test.style.visibility= "hidden ";
}
</script>
<body>
<span onmouseover= "ShowDiv() " onmouseout= "HiddenDiv() "> move here </span>

<div id= "test " style= "position:absolute;visibility:hidden;width:200;height:200;border:1 black solid;background-color:#FFFFCC " onmouseover= "this.style.visibility= 'visible ' " onmouseout= "this.style.visibility= 'hidden ' "> i 'm test </div>
</body>
</html>
参考一下吧
[解决办法]
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head>
<style type= "text/css ">
.cPopText
{
filter: Alpha(Opacity=0);
}
</style>
</head>
<body>
<table width= "200px " onmouseover= "showPopupText(event); " onmouseout= "hidePopupText(event); " border= "1 ">
<tr> <td> line1 </td> </tr>
</table> <br />
<table width= "200px " onmouseover= "showPopupText(event); " onmouseout= "hidePopupText(event); " border= "1 ">
<tr> <td> line2 </td> </tr>
</table> <br />
<table width= "200px " onmouseover= "showPopupText(event); " onmouseout= "hidePopupText(event); " border= "1 ">
<tr> <td> line3 </td> </tr>
</table>
</body>
</html>
<script type= "text/javascript ">

//***********默认设置定义.*********************
tPopWait=1; //停留tWait豪秒后显示提示。
tPopShow=60000; //显示tShow豪秒后关闭提示
showPopStep=20;
popOpacity=50;

//***************内部变量定义*****************
sPop=null;
curShow=null;
tFadeOut=null;
tFadeIn=null;
tFadeWaiting=null;
MouseX=0;
MouseY=0;
popLeftAdjust=0;
popTopAdjust=0;

function showPopupText(e)
{
e = window.event || e;
var o = e.srcElement || e.target;
MouseX=e.clientX ;
MouseY=e.clientY;
clearTimeout(curShow);
clearTimeout(tFadeOut);
clearTimeout(tFadeIn);
clearTimeout(tFadeWaiting);
curShow=setTimeout( "showIt() ",tPopWait);
}

function showIt()
{
var odyp = document.getElementById( 'dypopLayer ');

var popWidth = odyp.clientWidth;


var popHeight = odyp.clientHeight;

//alert( 'odyp.clientWidth= ' + odyp.clientWidth + ',body.clientWidth= ' + popWidth);

if(MouseX+12+popWidth > document.body.clientWidth)
{popLeftAdjust = -popWidth-24;}
else
{popLeftAdjust=0;}

if(MouseY+12+popHeight > document.body.clientHeight)
{popTopAdjust=-popHeight-24;}
else
{popTopAdjust=0;}

odyp.style.left = MouseX+12+document.body.scrollLeft+popLeftAdjust;
odyp.style.top = MouseY+12+document.body.scrollTop+popTopAdjust;
odyp.style.filter = "Alpha(Opacity=0) ";

fadeOut();
}

function fadeOut()
{
var odyp = document.getElementById( 'dypopLayer ');
if(odyp.filters.Alpha.opacity <popOpacity)
{
odyp.filters.Alpha.opacity+=showPopStep;
tFadeOut=setTimeout( "fadeOut() ",1);
}
else
{
odyp.filters.Alpha.opacity=popOpacity;
tFadeWaiting=setTimeout( "fadeIn() ",tPopShow);
}
}

function fadeIn()
{
var odyp = document.getElementById( 'dypopLayer ');
if(odyp.filters.Alpha.opacity> 0)
{
odyp.filters.Alpha.opacity-=1;
tFadeIn=setTimeout( "fadeIn() ",1);
}
}

function hidePopupText(e)
{
document.all.dypopLayer.style.display= ' ';
}

function showClick()
{
document.getElementById( 'dypopLayer ').style.display= ' ';
}
function hideClick()
{
document.getElementById( 'dypopLayer ').style.display= 'none ';
}

-->
</script>
<script type= "text/javascript ">
function CreateDypopLayer()
{
var odiv = document.createElement( "div ");
odiv.id= "dypopLayer ";
odiv.style.position = "absolute ";
odiv.style.zIndex = "1000 ";
odiv.style.width= "112px ";
odiv.style.height= "29px ";
odiv.className= "cPopText ";
odiv.innerHTML= " <img src=\ "http://zi.csdn.net/ebay_300.60.gif\ " border=\ "0\ " /> ";
odiv.setAttribute( "onmouseover ", "showClick(); ");
odiv.setAttribute( "onmouseout ", "hideClick(); ")
odiv.style.display= "none ";
document.body.appendChild(odiv);
}

CreateDypopLayer();

</script>
[解决办法]
已经在你的另一篇帖子里面回复
firefox使用事件的时候需要注意的问题

热点排行