Skip to content

Instantly share code, notes, and snippets.

@zerkms
Created July 16, 2013 23:22
Show Gist options
  • Save zerkms/6016151 to your computer and use it in GitHub Desktop.
Save zerkms/6016151 to your computer and use it in GitHub Desktop.
<!--
Copyright 2004 ThoughtWorks, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>Moveto Test Page</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
#moveto {
border: 1px black dashed;
width: 200px;
height: 200px;
background-color: red;
}
</style>
<script type="text/javascript">
window.addEventListener('load', function load() {
window.removeEventListener('load', load, false);
init();
}, false);
function init() {
var movetoDiv = document.getElementById('moveto');
movetoDiv.addEventListener('mouseup', function(e) {
document.getElementById('up').innerHTML = e.clientX + ',' + e.clientY;
});
movetoDiv.addEventListener('mousedown', function(e) {
document.getElementById('down').innerHTML = e.clientX + ',' + e.clientY;
});
movetoDiv.addEventListener('click', function(e) {
document.getElementById('click').innerHTML = e.clientX + ',' + e.clientY;
});
}
</script>
</head>
<body>
<div id="moveto"></div>
<div id="down"></div>
<div id="up"></div>
<div id="click"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment