JavaScript

[HTML_Objects] JS - <map> 객체 - 이미지맵 (= map태그 = 이미지맵태그) ※ 이미지 특정 부분에 링크

목차

  1. <map> 객체 정의 - 이미지맵
  2. <map> 객체 구문
  3. <map> 객체 예제 - 접근
  4. <map> 객체 예제 - 생성
  5. <map> 객체 집합
  6. <map> 객체 속성

 

<map> 객체 정의 - 이미지맵

 

HTML <map> 태그(요소) 의미.

 

 

<map> 객체 구문

 

[접근]

var x = document.getElementById("요소ID");

 

[생성]

var x = document.createElement("MAP");

 

 

<map> 객체 예제 - 접근

 

<img src="https://i.imgur.com/TpbgVeE.gif" width="389" height="26" border="0" usemap="#hz">

<map name="hz" id="hz">

  <area shape="rect" coords="4,3,68,21" href="http://naver.com" target="_blank" onFocus="blur()">

  <area shape="rect" coords="78,4,119,20" href="http://daum.net" target="_blank" onFocus="blur()">

  <area shape="rect" coords="128,5,193,19" href="http://www.paran.com" target="_blank" onFocus="blur()">

  <area shape="rect" coords="204,3,259,20" href="http://nate.com" target="_blank" onFocus="blur()">

  <area shape="rect" coords="269,2,323,20" href="http://www.google.co.kr/" target="_blank" onFocus="blur()">

  <area shape="rect" coords="331,4,385,18" href="http://kr.yahoo.com/" target="_blank" onFocus="blur()">

</map>


<button onclick="homzzang()">클릭</button>


<p id="demo"></p>


<script>

function homzzang() {

  var x = document.getElementById("hz").areas.length;

  document.getElementById("demo").innerHTML = x;

}

</script> 

 

결과보기 

 

<map> 객체 예제 - 생성

 

<img src="https://i.imgur.com/TpbgVeE.gif" width="389" height="26" border="0" usemap="#hz">


<button onclick="homzzang()">클릭</button>


<p id="demo"></p>


<script>

function homzzang() {

  var x = document.createElement("MAP");

  x.setAttribute("id", "hz");

  x.setAttribute("name", "hz");

  document.body.appendChild(x);


  var y = document.createElement("AREA");

  y.setAttribute("href", "https://naver.com");

  y.setAttribute("shape", "rect");

  y.setAttribute("coords", "4,3,68,21");

  document.getElementById("hz").appendChild(y);


  document.getElementById("demo").innerHTML = "생성완료. 클릭 가능.";

}

</script>

 

결과보기

 

<map> 객체 집합

 

area

imagemap의 모든 <area> 요소 집합 반환.

 

images

imagemap과 관련된 모든 <img> 및 <object> 요소의 집합 반환. 

 

 

<map> 객체 속성

 

name

imagemap의 name 속성값 설정/반환. 

 

※ <map> 객체는 표준 속성/메서드/이벤트 지원.


분류 제목
DOM_Style JS - borderBottomRightRadius 속성 - 테두리하단오른쪽모서리둥글게 설정/반환 (= 테두…
DOM_Style JS - borderBottomStyle 속성 - 테두리하단스타일
DOM_Style JS - borderBottomWidth 속성 - 테두리하단두께 (= 하단테두리두께 = 보더바텀위드스 = b…
DOM_Style JS - borderCollapse 속성 - 테두리겹침설정 (= 테두리중첩설정 = 테두리이중방지 = 보더컬랩…
DOM_Style JS - borderColor 속성 - 테두리색깔 설정/반환 (= borderColor속성 = 보더컬러 속성…
DOM_Style JS - borderImage 속성 - 테두리이미지 설정/반환 (= borderImage속성 = 보더이미지속…
DOM_Style JS - borderImageOutset -
DOM_Style JS - borderImageRepeat -
DOM_Style JS - borderImageSlice -
DOM_Style JS - borderImageSource -
DOM_Style JS - borderImageWidth -
DOM_Style JS - borderLeft -
DOM_Style JS - borderLeftColor -
DOM_Style JS - borderLeftStyle -
DOM_Style JS - borderLeftWidth -
58/89
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 2
웹유틸
회원센터
홈짱닷컴 PC버전 로그인