Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <meta charset="utf-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6.     <meta name="viewport" content="width=device-width">
  7.  
  8.     <title>Cats</title>
  9.  
  10.     <link rel="stylesheet" href="">
  11.   </head>
  12.  
  13.   <body>
  14.     <button onclick = "chooseCat();">Click me =^^=</button>
  15.   </body>
  16.  
  17.   <script>
  18.     var catBase = {
  19.         address: ['http://www.morefunkyfun.com/latter_images/261903948Whoever-woke-me-up-is-going-to-die-cute-cat-kitty-funny-meme.jpg',
  20.                   //'2.jpg',
  21.                   'https://s-media-cache-ak0.pinimg.com/236x/20/78/7a/20787a56c6df78828b184e1dbd58fc00.jpg',
  22.                   //'4.jpg',
  23.                   'https://imgs.xkcd.com/comics/fourier.jpg'],
  24.         text: ['First cat\n',
  25.                'Second cat\n',
  26.                'Third cat\n']
  27.                //'Fourth cat\n',
  28.                //'Fifth cat\n',
  29.                //'Sixth cat\n'],
  30.     }
  31.  
  32.     function chooseCat() {
  33.         var input = prompt("Enter 1-3 to see a cat");
  34.         --input;
  35.         showCat(input);
  36.     }
  37.    
  38.     function showCat(id) {
  39.         /*var img = document.hasOwnProperty("img");
  40.         document.write("meow0");
  41.         if(img != undefined) {
  42.             document.write("meow1");
  43.             img = document.getElementById("img");
  44.             img.parentNode.removeChild(img);
  45.         }
  46.         document.write("meow2");*/
  47.         var img = document.createElement("img");
  48.         img.src = catBase.address[id];
  49.        
  50.         document.body.appendChild(img);
  51.         alert(catBase.text[id]);
  52.     }
  53.  
  54.  
  55.  
  56.   </script>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement