Created
July 24, 2013 11:53
-
-
Save botverse/6069885 to your computer and use it in GitHub Desktop.
Test events inside a iframe with jquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function(){ | |
| $("body").mousemove(function(event){ | |
| $("#console").html("parent: " + event.pageX + ", " + event.pageY); | |
| }); | |
| var iframe = $("<iframe>").load(function(){ | |
| iframe.contents().mousemove(function(event){ | |
| var position = iframe.position(); | |
| $("#console").html("child : " + (event.pageX + position.left) + ", " + (event.pageY + position.top)); | |
| }); | |
| }); | |
| $("body").prepend(iframe) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Iframe events test</title> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| <style> | |
| iframe { | |
| margin: 80px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="console"></div> | |
| <script src="http://code.jquery.com/jquery.js" type="text/javascript"></script> | |
| <script src="eventstest.js" type="text/javascript"></script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment