-1

i am loading a external URL in iFrame and i want to check if user clicks anything inside iframe(which is URL content)

it's basically need to check if any content is getting changed in side iframe when i click anything inside iframe,

i have tried using asp.net and javascript but no luck.don't know if possible in jquery

even i tried to use div instead of iframe and load the url but still don't find any solution ..

i can see my main page gets refreshed when i clicks any links inside but no event gets fired.

user1818042
  • 75
  • 1
  • 11
  • Alternate solutions: https://stackoverflow.com/questions/2381336/detect-click-into-iframe-using-javascript/23231136#23231136 https://stackoverflow.com/questions/2381336/detect-click-into-iframe-using-javascript/32138108#32138108 Found on: https://stackoverflow.com/questions/2381336/detect-click-into-iframe-using-javascript – Robby Aug 11 '17 at 14:32
  • You can not do it because the webpage is external.... – epascarello Aug 11 '17 at 14:33
  • both are in same domain – user1818042 Aug 12 '17 at 08:51
  • Thanks Robby, i have tried the link u have given it's firing anywhere if click in url .but is it possible to capture in case user redirects inside iframe. may be if change any content.,, any way thanks for your help. – user1818042 Aug 12 '17 at 09:17

1 Answers1

0

attach a click event when the iframe loads up

$('#iframe').load(function() {
    $(this).contents().find('body').on('click', function(event) {
        alert('clicked');
    }
}
Danyal Imran
  • 2,515
  • 13
  • 21