onmouseout 超链接求助

发布网友

我来回答

2个回答

热心网友

这个是一个DIV显示隐藏的例子,你可以参考一下

<script language="javascript">
var tips;
var theTop = 40;
var old = theTop;
function initFloatTips()
{
tips = document.getElementById('divQQbox');
moveTips();
}
function moveTips()
{
var tt=50;
if (window.innerHeight)
{
pos = window.pageYOffset
}else if (document.documentElement && document.documentElement.scrollTop) {
pos = document.documentElement.scrollTop
}else if (document.body) {
pos = document.body.scrollTop;
}
pos=pos-tips.offsetTop+theTop;
pos=tips.offsetTop+pos/10;
if (pos < theTop){
pos = theTop;
}
if (pos != old) {
tips.style.top = pos+"px";
tt=10; //alert(tips.style.top);
}
old = pos;
setTimeout(moveTips,tt);
}
initFloatTips();
if(typeof(HTMLElement)!="undefined") //给firefox定义contains()方法,ie下不起作用
{
HTMLElement.prototype.contains=function (obj)
{
while(obj!=null&&typeof(obj.tagName)!="undefind"){ //通过循环对比来判断是不是obj的父元素
if(obj==this) return true;
obj=obj.parentNode;
}
return false;
}
}
function show()
{
document.getElementById("meumid").style.display="none"
document.getElementById("contentid").style.display="block"
}
function hideMsgBox(theEvent){
if (theEvent){
var browser=navigator.userAgent;
if (browser.indexOf("Firefox")>0){ //如果是Firefox
if (document.getElementById("contentid").contains(theEvent.relatedTarget)) { //如果是子元素
return
}
}
if (browser.indexOf("MSIE")>0 || browser.indexOf("Presto")>=0){ //如果是IE
if (document.getElementById('contentid').contains(event.toElement)) { //如果是子元素
return; //结束函式
}
}
}
document.getElementById("meumid").style.display = "block";
document.getElementById("contentid").style.display = "none";
}
</script>

<div class="qqlv" id="meumid" onmouseover="show()"></div>
<div class="qqkf" style="display:none;" id="contentid" onmouseout="hideMsgBox(event)">
</div>

===================================

不知道你的版本是否跟我的一样,或者使用上有偏差,我本机测试是没有问题的,兼容IE和FireFox,FireFox的版本是3.6.3

热心网友

太强了,我这儿有个简单的,哈哈

<div id="addds" onmouseover="mover(this)" onmouseout="mout(this)" style="width:300px; height:150px; background-color:#0F9;"> 在一个div里 我想要鼠标离开这个div时 display:none
但是如果这个div里有超链接时
即使鼠标在div内 <a href="http://hi.baidu.com/javaplan" > 只要移动到超链接上</a>
<a href="http://hi.baidu.com/javaplan">电脑会默认为离开这个div了</a>
div自动 displa:none了
</div>
<script type="text/javascript" language="javascript">
function mover(obj)
{
document.getElementById(obj.id).style.display="";
}
function mout(obj)
{
document.getElementById(obj.id).style.display="none";
}
</script>

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com