Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<script>
document.getElementById('mainDocumentBody').addEventListener('MouseMove', changeButtonPosition);
function changeButtonPosition(){
document.getElementById('button1').style.left = window.event.screenX;
alert("x="+window.event.screenX+" y="+window.event.screenY);
}
</script>
<div id='mainDocumentBody' border="2" width="100%" height="100%">
<button id='button1'>New Game</button>
</div>
<script>
</script>
</body>
</html>
I know the code has syntax errors perhaps, but I am here to find out how to do it the right way.
Some help with be appreciated.
Thanks.