滚动会导致 IE9 中的页面滚动和地图缩放(Google 地图 v2)
在 Internet Explorer 9 中,使用 Google Maps API v2(已弃用),使用滚轮缩放也会导致页面滚动。有谁知道这个问题的解决方法? (遗憾的是,目前还无法将我们的代码库升级到 v3。)早期版本的 Internet Explorer 中不会出现此行为。
In Internet Explorer 9, using the Google Maps API v2 (which is deprecated), zooming with the scroll wheel also causes the page to scroll. Does anyone know of a workaround for this issue? (Upgrading our codebase to v3 is not yet possible, unfortunately.) This behavior does not occur in earlier versions of Internet Explorer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
网上似乎有很多人有同样的问题,但我没有找到解决方案。这是我的:
由于不可滚动组件不会引发滚动事件,并且该事件在文档对象上是不可取消的,因此无法使用标准 DOM。幸运的是,有一个名为“mousewheel”的 jQuery 小插件,它为 jQuery 添加了“mousewheel”和“unmousewheel”事件绑定功能。 “mousewheel”事件调用的函数可以返回 false 以取消它,然后文档不会接收它。因此,我测试了 IE9 或更高版本,并在必要时下载这个小插件,将其应用到保存地图的 div 上。
Many people seem to have the same problem around the net but I found no solutions posted. So here is mine:
Since non-scrollable components do not raise the scroll event and that event is non-cancelable on the document object, the standard DOM could not be used. Fortunately, there is a little jQuery plugin called "mousewheel", which adds "mousewheel" and "unmousewheel" event binding functions to jQuery. The function called by "mousewheel" event can return false to cancel it and the document then does not receive it. So I test for IE9 or bigger and download this little plugin if necessary, applying it to the div holding the map.
请尝试
此代码隐藏滚动条。我发现这只是在 IE 中禁用滚动的一种方法。
document.body.scroll = "no"
不起作用。 ( IE9 )#map - 是带有谷歌地图的 div,
#wrapper - 是包含所有页面的 div。
$('#wrap').css('margin-right','17px');
// 只是为了在左侧滚动条隐藏/显示时保持页面宽度Please try
This code hide scrollbars. I found that it is only one way to disable scrolling in IE.
document.body.scroll = "no"
don't work. ( IE9 )The #map - is div with google map,
the #wraper - is div with all page.
$('#wrap').css('margin-right','17px');
// just to keep page width when left scroll bar hided/showed要使用 PrototypeJS 1.7 解决此问题(如 Marek 和 theazureshadow 建议),您可以在 IE9 上使用:
To fix this problem with PrototypeJS 1.7 (like Marek and theazureshadow suggest) you can use on IE9:
我遇到了同样的问题,并通过以下方式解决:
当光标位于地图元素上并且滚轮移动时,将禁用整页滚动。只有地图会放大或缩小
I had the same problem, and solve it this way:
When cursor is over map element and scrollwheel moves, whole-page-scrolling will be disabled. Only map will zoom in or out