查找区域的 target 属性的值

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <img src ="/i/eg_planets.jpg"
  6. alt="Planets"
  7. usemap ="#planetmap" />
  8.  
  9. <map name ="planetmap">
  10. <area shape ="circle" coords ="180,139,14"
  11. href ="/example/hdom/venus.html" id="venus"
  12. target="_self"/>
  13. </map>
  14.  
  15. <p>单击按钮可返回图像映射中“venus”区域的 target 属性值。</p>
  16.  
  17. <button onclick="myFunction()">试一试</button>
  18.  
  19. <p id="demo"></p>
  20.  
  21. <script>
  22. function myFunction() {
  23. var x = document.getElementById("venus").target;
  24. document.getElementById("demo").innerHTML = x;
  25. }
  26. </script>
  27.  
  28. </body>
  29. </html>