1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| (function() {
var myhtml = document.getElementsByTagName("html") [0],
mybody = document.getElementsByTagName("body") [0],
posX,
posY,
bouge;
addEventListener(window, 'load', function () {
addEventListener(mybody, 'mousedown', function () {
bouge = true;
}, false);
addEventListener(mybody, 'mousemove', function (e) {
if (bouge = true) {
posX = e.clientX;
posY = e.clientY;
var div = document.createElement('div');
div.style.width = '2px';
div.style.height = '2px';
div.style.backgroundColor = 'black';
div.style.position = 'absolute';
div.style.left = posX;
div.style.top = posY;
mybody.appendChild(div);
}
}, false);
addEventListener(mybody, 'mouseout', function () {
bouge = false;
}, false);
}, false);
})(); |
Partager