javascript - Detecting when user touches a link -


i'm trying detect when user has touched link within web page versus when have touched other part of page, not working - happens in following code alert "touched non link" pops wherever touch, regardless of if link.

what there problem code?

function addlisteners() {       alert('adding listeners');      // attach listener touches on non-links document node     document.addeventlistener("touchstart", touchesonnonlinkslisterner, false);      // attach listener touches on links anchor nodes     var links = document.getelementsbytagname("a");     (var index = 0; index < links.length; ++index)     {         links[index].addeventlistener("touchstart", touchesonnonlinkslisterner, false);     } };   function touchesonnonlinkslisterner(event) // catches touches anywhere in document {     alert("touched  non link"); }  function touchesonlinkslistener(event) // listens touches occur on links, prevents touch events bubbling trigger touchesonnonlinkslisterner {     alert("touched link");     if (typeof event == "undefined")     {         event = window.event;     }      event.stoppropegation(); } 

you have attached touchesonnonlinkslisterner links well. attach touchesonlinkslistener instead!


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -