0

我创建了一个非常基本的页面来说明这一点......

<!DOCTYPE html>
<html> <!-- manifest="cache.manifest"-->
<head>

<title>FireFox Touch TEST</title>

<style>

body {width:100%; height:100%; background-color:green;}
div.testdiv {top:0px; left:0px; width:1in; height:1in; background-color:blue;}

</style>

</head> 
<body class="body">

<div id="test" class="testdiv">Touch here</div>

<script type="text/javascript">

  function tStart(event)
  {
    alert("Touched");
  }

  divid = document.getElementById("test");
  divid.addEventListener('touchstart', function(){tStart(event)},false);

</script>   
</body>
</html>

我似乎要么做一些根本错误的事情,要么在 android 4.2.2 上移动 Firefox 24 有问题

有任何想法吗...

4

1 回答 1

3

试试这样:

tStart()由于调用中没有这样的变量event,浏览器会查看全局对象中是否定义了事件。在 JavaScript 中,全局对象被称为window

function tStart(event)
{
    alert("Touched");
}

 divid = document.getElementById("test");
 divid.addEventListener('touchstart', function(){tStart(window.event)},false);
于 2013-10-17T10:03:20.283 回答