jscrollpane 鼠标滚轮事件仅针对 ie/ff 中的滚动轨道区域触发
这是我正在使用的代码..mousewheel 仅针对滚动轨道区域而不针对整个 div/iframe 触发..
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="style/jquery.jscrollpane.css">
<script type="text/javascript" src="script/jquery-1.3.2.js"></script>
<script src="script/jquery.jscrollpane.js"></script>
<script src="script/jquery.mousewheel.js"></script>
<script src="script/jquery.jscrollpane.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#test').jScrollPane({ showArrows:true , scrollbarWidth:5});
});
</script>
</head>
<body>
<div id="test" style="height:300px;width:900px;overflow: auto;">
<iframe style="height:1300px;width:900px;" src="http://www.google.com" scrolling="no"></iframe>
</div>
</body>
</html>
here is code i am using..mousewheel firing only for scroll track area not for whole div/iframe..
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="style/jquery.jscrollpane.css">
<script type="text/javascript" src="script/jquery-1.3.2.js"></script>
<script src="script/jquery.jscrollpane.js"></script>
<script src="script/jquery.mousewheel.js"></script>
<script src="script/jquery.jscrollpane.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#test').jScrollPane({ showArrows:true , scrollbarWidth:5});
});
</script>
</head>
<body>
<div id="test" style="height:300px;width:900px;overflow: auto;">
<iframe style="height:1300px;width:900px;" src="http://www.google.com" scrolling="no"></iframe>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
iframe 会吃掉你所有的事件。您要么必须删除 iframe,要么在其顶部放置一个透明元素来捕获事件(但这会使 iframe 不可交互)。
An iframe is going to eat up all your events. You'll either have to get rid of the iframe, or put a transparent element on top of it to catch the events (that'll however make the iframe non-interactable).
我已经回答了这个问题两者 次 您在 Google 代码上询问过该问题 jScrollPane 邮件列表。
正如 Matti 所说,iframe 正在捕获滚动事件,您无法从托管页面访问它们。唯一可靠的解决方案(如果您可以控制嵌入页面)如下例所示:
http://jscrollpane .kelvinluck.com/iframe.html
I already answered this question both times you asked it on google code and on the jScrollPane mailing list.
As Matti says, the iframe is catching the scroll events and you can't access them from the hosting page. The only reliable solution (if you have control over the embedded page) is shown in this example:
http://jscrollpane.kelvinluck.com/iframe.html