Javascript - Image Popup


SUBMITTED BY: Guest

DATE: Oct. 8, 2013, 10 p.m.

FORMAT: JavaScript

SIZE: 1.6 kB

HITS: 1481

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <style>
  6. #Container
  7. {
  8. width: 100%;
  9. height: 100%;
  10. }
  11. #Thumbs,
  12. #BigImgDiv
  13. {
  14. width:100%;
  15. height:100%;
  16. position:absolute;
  17. }
  18. #BigImgDiv
  19. {
  20. background-color:black;
  21. z-index:1;
  22. left:0px;
  23. top:0px;
  24. display:none;
  25. }
  26. #BigImg
  27. {
  28. position: absolute;
  29. margin: auto;
  30. top: 0;
  31. left: 0;
  32. right: 0;
  33. bottom: 0;
  34. }
  35. </style>
  36. <script>
  37. function expandImage(image) {
  38. var bigDiv = document.getElementById("BigImgDiv");
  39. bigDiv.innerHTML = "<img src='" + image + "' id='BigImg' />";
  40. bigDiv.style.display = "block";
  41. }
  42. function hideImage() {
  43. var bigDiv = document.getElementById("BigImgDiv");
  44. bigDiv.style.display = "none";
  45. }
  46. </script>
  47. </head>
  48. <body>
  49. <div id="Container">
  50. <div id="BigImgDiv" onclick="hideImage();"></div>
  51. <div id="Thumbs">
  52. <img src="image1.png" onclick="expandImage('bigimage1.png');" />
  53. <img src="image2.png" onclick="expandImage('bigimage2.png');" />
  54. </div>
  55. </div>
  56. </body>
  57. </html>

comments powered by Disqus