• 회원가입
  • 로그인
  • 구글아이디로 로그인

[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> 객체는 표준 속성/메서드/이벤트 지원.

방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
Basic JS - Home (JS입문) + Javascript Framework (프레임워크) 종류
Basic JS - Intro (JS소개)
Basic JS - Where To (JS위치) - JS구문 / JS코드위치 / JS사용법 ※ JS외부링크 주의사항
Basic JS - Output (JS출력= JS쓰기) ★★★★★
Basic JS - Syntax (JS구문) ★
Basic JS - Statement (JS구문= JS명령문)
Basic JS - Comment (JS주석)
Basic JS - Variable (JS변수) ★★★★★
Basic JS - Operator (연산자) - JS연산자 ★★★★★
Basic JS - Data Type - 데이터유형 ★★★★★ (= 데이터형식 = 데이터타입 = 데이터종류 = 자료형…
Basic JS - Function - JS함수 ★★★★★ ※ 일반함수 특징 2
Basic JS - Object - JS객체 ★★★★★
Basic JS - Scope - JS유효범위 (= JS접근범위 = 변수 종류) ★★★★★★★★★★
Basic JS - Event - JS이벤트 (= JS코드실행방법) ★★★★★
Basic JS - Strings - JS문자열
Basic JS - String Methods - JS문자열메서드
Basic JS - Number - JS숫자
Basic JS - Number Method - JS숫자메서드
Basic JS - Math 객체 - JS수학객체 (= JS산수객체 = Math객체 = Math Object = 매스 …
Basic JS - Dates - JS날짜
1/67
목록
찾아주셔서 감사합니다. Since 2012