PraveenHarris
PraveenHarris

Reputation: 869

How to make JavaScript click a certain position?

I'm new to JavaScript/HTML. I wanted to find out how I can get JavaScript to click a certain location. I would prefer it if no only basic/intermediate JavaScript is used, however the advanced JavaScript is also welcome.

Upvotes: 1

Views: 4828

Answers (1)

Feathercrown
Feathercrown

Reputation: 2591

Yes it is possible, and has already been answered. See How to simulate a click by using x,y coordinates in JavaScript?:

You can dispatch a click event, though this is not the same as a real click. For instance, it can't be used to trick a cross-domain iframe document into thinking it was clicked.

All modern browsers support document.elementFromPoint and HTMLElement.prototype.click(), since at least IE 6, Firefox 5, any version of Chrome and probably any version of Safari you're likely to care about. It will even follow links and submit forms:

document.elementFromPoint(x, y).click(); https://developer.mozilla.org/En/DOM:document.elementFromPoint https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click

Upvotes: 0

Related Questions