Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Задание №2</title>
- <script type="text/javascript" src="scripts/task8.js">
- var div,
- mousex,
- mousey,
- active=false;
- function start() {
- div=document.getElementById("maindiv");
- window.setInterval("run();", 5);
- }
- function run() {
- if (parseInt(div.style.top, 10)>mousey) {
- //div.style.top=parseInt(div.style.top,10)-1;
- div.style.top=mousey;
- } else {
- if (parseInt(div.style.top, 10)<mousey) {
- //div.style.top=parseInt(div.style.top, 10)+1;
- div.style.top=mousey;
- }
- }
- if (parseInt(div.style.left, 10)>mousex) {
- //div.style.left=parseInt(div.style.left, 10)-1;
- div.style.left=mousex;
- } else {
- if (parseInt(div.style.left, 10)<mousex) {
- //div.style.left=parseInt(div.style.left, 10)+1;
- div.style.left=mousex;
- }
- }
- }
- function move(event) {
- window.mousex=event.clientX;
- window.mousey=event.clientY;
- }
- </script>
- </head>
- <body onload="start();" onmousemove="move(event);">
- <div style="z-index=2;" id="maindiv">Мельников</div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement