3

I am overlaying hidden rectangle on my iframe. Then Detecting click inside my rectangular region. Then i will take its (X,Y) and simulate a click inside iframe on same coordinate(X,Y).

This way, i will pass user's click on hidden rectangular area to iframe as it is not possible to directly detect events on iframe because of security issues.

This will bypass that issue.

Some problem with my code. Not able to pass click to iframe on triggering.

Here is Js Fiddle

http://jsfiddle.net/biggenius/Y8cVD/9/

Here is a way to click inside box. http://jsfiddle.net/styson/PxcBs/1/

How to detect click on Overlay?http://jsfiddle.net/biggenius/Y8cVD/13/

Here are some solution worth considering. http://stackoverflow.com/questions/10226448/detecting-click-inside-iframe-using-invisible-div/10226475#comment13139245_10226475

https://i.stack.imgur.com/fQiJT.png

Oscar Kelton
  • 107
  • 1
  • 9

1 Answers1

3

You mean like this? There were a couple of missing brackets/slight syntax errors in your fiddle :)

Demo: http://jsfiddle.net/Y8cVD/14/

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
  • Can you please, shift that overlay over any button, and pass click from overlay to iframe behind it? – Robert Lowery Apr 20 '12 at 07:53
  • Just so I understand fully, you want the overlay to move over any button when that button is hovered? Or do you want to move the overlay over all buttons by default and pass the click to the iframe? – Mathew Thompson Apr 20 '12 at 10:50
  • Yes, i want to put overlay over frame, then pass click to button. As i can't directly access iframe. Due to security issues. – Robert Lowery Apr 20 '12 at 11:09
  • Something like this? http://jsfiddle.net/Y8cVD/24/ Note that you'll have to wait until the iframe is fully loaded in the fiddle :) – Mathew Thompson Apr 20 '12 at 11:17
  • I want to pass my click to the iframe. – Robert Lowery Apr 20 '12 at 12:25
  • Overlay of button. Then detect click on overlay and simulate click at same place to the iframe behind overlway. Hope it helps. I am confused , how to make it work. – Robert Lowery Apr 20 '12 at 12:27
  • http://jsfiddle.net/Y8cVD/14/ In this, i need to put overlway over "downloads" And then detect this click and pass it on to iframe. So actually button gets clicked. – Robert Lowery Apr 20 '12 at 12:29
  • Ah okay, do you want only the "downloads" button to be clicked when the overlay is clicked? Or do you want all of the buttons to be clicked when the overlay is clicked (depending on the x and y of the click) – Mathew Thompson Apr 20 '12 at 12:33
  • Overlay only over Download button, not full iframe. And need to just click download button, when clicked inside overlay. – Robert Lowery Apr 20 '12 at 12:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/10339/discussion-between-robert-lowery-and-mattytommo) – Robert Lowery Apr 21 '12 at 02:59
  • @mattytommo, may I ask you to have a look at a click related question here : https://stackoverflow.com/questions/51468968/jquery-click-at-a-co-ordinate-on-an-image-and-draw-a-circle-there ? – Istiaque Ahmed Jul 29 '18 at 14:29