Skip to content

Instantly share code, notes, and snippets.

@YenTheFirst
Created February 6, 2013 20:24
Show Gist options
  • Save YenTheFirst/4725480 to your computer and use it in GitHub Desktop.
Save YenTheFirst/4725480 to your computer and use it in GitHub Desktop.
repost of previous
<html>
<head>
<style type="text/css">
#over{
position: absolute;
left: 20;
}
</style>
<script type="text/javascript">
window.onload = function() {
console.log('loaded');
document.getElementById('base').onclick = function(e) {
console.log('base got clicked');
}
document.getElementById('over').onclick = function(e) {
this.hidden = true;
new_target = document.elementFromPoint(e.x,e.y);
this.hidden = false;
new_e = document.createEvent("MouseEvents");
new_e.initMouseEvent(e.type,e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget);
new_target.dispatchEvent(new_e);
e.preventDefault();
}
}
</script>
</head>
<body>
<img src='http://placekitten.com/512/256' id='base'>
<img src='http://placekitten.com/256/256' id='over'>
blah
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment