javascript - Keypress event to web page not working from iframe -



javascript - Keypress event to web page not working from iframe -

i created web page using html , javascript. used iframe within page , assigned keypress event window like,

<html> <head> <title>keypress event test</title> <script type="text/javascript"> function onkeypress(e){alert(e.keycode);} window.addeventlistener("keypress", onkeypress); </script> </head> <body> <h1>helow! welcome!</h1> <iframe src="..." /> </body> </html>

on key press alert working fine. after click iframe , press key function not working. how can bring keypress event iframe?

if place iframes on page, browser create window object page, , 1 each iframe.

i suspect cause of problem, since code not explicitly window object attach keypress event to.

javascript html keypress

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -