2014年4月14日 星期一

Lab 17 JavaScript

產生三個文字方塊,上面各寫1, 2, 3
這三個方塊上方可以顯現照片,當滑鼠置於文字1的時候,
顯示照片A 當滑鼠置於文字2的時候,
顯示照片B 當滑鼠置於文字3的時候,顯示照片C

 =================================

Pet 001 Pet 002 Pet 003

<html>
 <body>
  <div id="Layer" style="display: none; position: absolute; z-index: 1;">
  </div>
  <span onmousemove="showPic('http://www.fotobeginner.com/wp-content/uploads/0017.jpg')" onmouseout="hidePic()">Pet 001</span>
  <p>
  <span onmousemove="showPic('http://ext.pimg.tw/littlething/1203403642.jpg')" onmouseout="hidePic()">Pet 002</span>
  <p>
  <span onmousemove="showPic('http://images2.gamme.com.tw/news/2013/02/1/o5qYn52ckKOVp6c.jpg')" onmouseout="hidePic()">Pet 003</span>
  <p>
  </body>
 <script>
  function hidePic(){
   document.getElementById("Layer").innerHTML = "";
   document.getElementById("Layer").style.display = "none";
  }
  function showPic(s){
   var x,y;
   x = event.clientX;
   y = event.clientY;
   document.getElementById("Layer").style.left = x;
   document.getElementById("Layer").style.top = y;
   document.getElementById("Layer").innerHTML = "<img src=\""+s+"\">";
   document.getElementById("Layer").style.display = "block";
  }
 </script>
</html>

沒有留言:

張貼留言