• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
小码哥-倩倩
博客园    首页    新随笔    联系   管理    订阅  订阅

chrome浏览器禁止缩放时报错

问题描述:禁止浏览器缩放的时候,谷歌浏览器老是提示[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080,浏览器依旧可以进行缩放。但是ctr和+的就可以禁止缩放。

原因:The wheel/mousewheel event listeners that are registered on document level targets (window.document, window.document.body, or window) will be treated as passive if not specified as otherwise and calling preventDefault() inside such listeners will be ignored. This is the wheel version of the scrolling intervention which is shipped in Chrome 56

翻译:在文档级目标(window.document、window.document.body或window)上注册的wheel/mousewheel事件监听器将被视为被动的(如果未指定为被动的),并且在此类监听器内调用preventdefault()将被忽略。这是Chrome56中提供的滚动干预的车轮版本

所以需要把scroll事件应该绑定在某个元素上,而不能绑定在window   body  document 上。

posted @ 2019-06-10 13:51  小码哥-倩倩  阅读(695)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3