TJS101
TJS101

Reputation: 500

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

Any ideas...

Upvotes: 0

Views: 2252

Answers (1)

Dhaval Marthak
Dhaval Marthak

Reputation: 17366

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. In JavaScript, the global object is called window

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

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

Upvotes: 3

Related Questions