Skip to content

Instantly share code, notes, and snippets.

@hpbuniat
Created May 7, 2012 15:48
Show Gist options
  • Save hpbuniat/2628544 to your computer and use it in GitHub Desktop.
Save hpbuniat/2628544 to your computer and use it in GitHub Desktop.
Test for tracking clicks within an iframe
<!DOCTYPE html>
<html>
<head>
<meta content="Hans-Peter Buniat" name="author">
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>test iframe clicks</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var f = {
b: false,
init: function(i) {
var t = this;
i.mouseover(function() {
console.log('over');
t.b = true;
}).mouseout(function() {
console.log('out');
t.b = false;
top.focus();
});
$(top).blur(function(e) {
if (t.b) {
console.log('click');
}
});
}
};
f.init($('iframe'));
});
</script>
</head>
<body>
<iframe src="http://www.fluege.de" width="50%" height="50%"></iframe>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment