TouchEvent无法在firefox和其他网站浏览器中运行 [英] TouchEvent not working in firefox and other website browser

查看:186
本文介绍了TouchEvent无法在firefox和其他网站浏览器中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,在Chrome中它运行良好,但它不会在firefox中触发

I have a problem, in chrome it runs well, but it won't fire in firefox

function normalizeEvent(e){     
  if(e.originalEvent instanceof TouchList){
    do somethings    
   }
}

这里是消息错误:ReferenceError:未定义TouchEvent

and here is message error: ReferenceError: TouchEvent is not defined

if(e.originalEvent instanceof TouchEvent){}


推荐答案

旧的问题,但是也许有人会在这里搜索解决方案(就像我一样)。

The old question, but maybe someone will search here the solution (as I did).

要在FF中工作,只需添加 window.TouchEvent 条件(已定义):

To get this work in FF, just add window.TouchEvent condition (is it defined):

if(window.TouchEvent&& e.originalEvent instanceof TouchEvent){}

这篇关于TouchEvent无法在firefox和其他网站浏览器中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆