Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Click tracking code triggers an infinite loop

I am using an event listener to track clicks on certain links. The links i would like to track are placed over images

I am using the following code and everything works fine on firefox but on chrome the code enters in infinite loop after clicking 3 times on the same page.

        function trackComp(event) {


  var clickedElement = (window.event) ? window.event.srcElement : e.target;

 
  var elem = clickedElement;
  var ape = [];
  while (elem.tagName != "HTML" && elem.tagName != "IMG") {
    var tuple = {
      "e": elem,
      "pe": elem.style.pointerEvents
    }; 
    ape.push(tuple);
 
    
    elem.style.pointerEvents = "none";
    console.log("cordinates x"+ event.x + "coordinates Y = " + event.y);
    elem = document.elementFromPoint(event.x, event.y);
    console.log(elem);
  } 
  
  // Check if element was found
  
  // Reset the pointer events
  while (ape.length > 0) {
    
    var tuple = ape.pop();
    tuple.e.style.pointerEvents = tuple.pe;
  }
  
}

Any ideas on what's wrong with this code ?

thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!