[英]Touch events in mobile firefox are not firing
I created a very basic page to illustrate this... 我创建了一个非常基本的页面来说明这一点...
<!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>
I seem to be either doing something fundamentally wrong or there is a problem with mobile firefox 24 on android 4.2.2 我似乎在做一些根本上错误的事情,或者Android 4.2.2上的移动Firefox 24有问题
Any ideas... 有任何想法吗...
Try like this: 尝试这样:
As there is no such a variable in tStart()
that calls event
, the browser looks if there is an event defined in the global object. 由于
tStart()
没有调用event
的变量,因此浏览器将查找全局对象中是否定义了事件。 In JavaScript, the global object is called window
在JavaScript中,全局对象称为
window
function tStart(event)
{
alert("Touched");
}
divid = document.getElementById("test");
divid.addEventListener('touchstart', function(){tStart(window.event)},false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.