Skip to content

Instantly share code, notes, and snippets.

@YenTheFirst
Created February 6, 2013 20:24
Show Gist options
  • Select an option

  • Save YenTheFirst/4725480 to your computer and use it in GitHub Desktop.

Select an option

Save YenTheFirst/4725480 to your computer and use it in GitHub Desktop.

Revisions

  1. YenTheFirst created this gist Feb 6, 2013.
    37 changes: 37 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    <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>