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

202
Views
Simulating a click on a page from my chrome extention

I have a chrome extension that finds the pageX and pageY of the window, Is there is a way to fire off a click event of a targeted element, say on google if I wanted to click on the search bar once If found the correct pageX and pageY.

I want to be able to click buttons etc. from the values calculated from my extension but I cant seem to get it to work from content-scripts.js so it there a way to send the pageX and pageY to the background.js scripts.

Something like this:

chrome.action.onClicked.addListener(function (tab) {
       chrome.tabs.executeScript(tab.id,{
           code: 'document.activeElement.click()'
       });
    });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can simulate click events in JavaScript using the .click() method of the target DOM element.

It's generally easier/more meaningful to interact with a page using document.querySelector() than it is to use X, Y coordinates, but you can do so using document.elementFromPoint().

function clickElementAtCoordinate(x, y) {
  const el = document.elementFromPoint(x, y);
  el.click();
}
``
about 4 years ago · Juan Pablo Isaza Report
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!