1

I have an iframe which I include on my page.

<iframe  scrolling="no" src="https://xx.com/" ></iframe>

xx.com doesn't allow cross-origin ( I don't remember how exactly is this parameter called, but I can't really access contents of iframe)

So what are my options to capture a keydown event which happens within this iframe? I tried

`$('iframe').keydown(function(e){console.log(1)});`

But didn't work(

user2950593
  • 9,233
  • 15
  • 67
  • 131

1 Answers1

0

Same as Add click event to iframe.

Live demo

$('iframe').load(function(){
  $(this).contents().find("body").on('keydown', function(event) { alert('test'); });
});
$('iframe').attr("src","JavaScript:'iframe content'");
Community
  • 1
  • 1
fumihwh
  • 1,239
  • 7
  • 13