document.getElementById( 'img' ).onclick = function (e) { e = e || window.event, var x = document.createElement( 'DIV' ); x.style.top = e.pageY, x.style.left = e.pageX; document.body.appendChild( x ); }