Wacky_rubia

html!!!!!!!!!!!!

Oct 11th, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.10 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <meta charset="utf-8">
  4.         <title>squares</title>
  5.     </head>
  6.     <body position=relative>
  7.        
  8.     </body>
  9. </html>
  10. <script>
  11.     function omRightMouse(e, elem) {
  12.         elem.parentNode.removeChild(elem);
  13.  
  14.     }
  15.  
  16.     var colors = ["red", "yellow", "blue", "green", "black", "gray"];
  17.     var i = 0;
  18.  
  19.     function onLeftMouse(e) {
  20.         var element = document.createElement('div');
  21.         element.style.backgroundColor = colors[i];
  22.         i++;
  23.         if (i == colors.length)
  24.             i = 0;
  25.         element.style.minWidth = '100px';
  26.         element.style.minHeight = '100px';
  27.         element.style.maxWidht = '100px';
  28.         element.style.maxHeight = '100px';
  29.         element.style.padding = '0px';
  30.         element.style.position = 'absolute';
  31.         element.style.left = e.pageX + 'px';
  32.         element.style.top = e.pageY + 'px';
  33.         element.oncontextmenu = function(e) { omRightMouse (e, this); return false }
  34.         document.body.appendChild(element);
  35.     }
  36.  
  37.     document.onclick = function(e) {
  38.         onLeftMouse(e);
  39.     }
  40.  
  41. </script>
Advertisement
Add Comment
Please, Sign In to add comment