<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
document.onmousewheel=function(){
alert("index");
}
</script>
</head><body>
<iframe src="http://www.baidu.com/" style="position:absolute; left:200px; top:100px; width:200px; height:200px;"></iframe>
</body>
</html>在safari下,当鼠标移进iframe页面时,滚动鼠标滚轮到尽头时会触发外面主页的鼠标滚轮事件,长时间在线等待,望高手解答,就只需解决在safari下鼠标滚轮事件不传递到外面的主页就行了,谢谢
这个帖子和我问的问题没多大的关系啊,你所发的贴是说如何捕捉浏览器的滚轮事件与滚动量的问题,在safari下用document.onmousewheel就可以捕捉。我所问的问题是怎么样切断iframe页面的滚轮事件,防止传递到主页页面上。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<div>
<iframe id="testframe" src="http://www.baidu.com/" style="position:absolute; left:200px; top:100px; width:200px; height:200px;"></iframe>
</div>
</body>
</html>
<script type="text/javascript">
function $(id){return document.getElementById(id);}
$("testframe").onmousewheel = function(){
return false;
}
</script>
看来我说的还是不够明白,我不是要取消外面index页面的滚轮事件,我还要保留index页面的monsewheel事件,我只是不想iframe内的页面中的滚轮事件和index页面的滚轮事件没有关联,是切断他们的联系。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
document.onmousewheel = function(){
alert("index");
}
</script>
</head>
<body>
<div>
<iframe id="testframe" src="http://www.baidu.com/" style="position:absolute; left:200px; top:100px; width:200px; height:200px;"></iframe>
</div>
</body>
</html>
<script type="text/javascript">
function $(id){return document.getElementById(id);}
$("testframe").onmousewheel = function(e){
e.stopPropagation();
return false;
}
</script>