자바스크립트객체  image, history, location

* Image객체
image에 관한 정보를 가지고 있는 객체를 말하며, name, src, height, width, hspace(가로여백), vspace(세로여백), border, align 등의 속성을 갖는다.

 

<html>
<head>

</head>
<body onclick="bgcol('pink','blue')">
<img name="img1" src="parksehun.png">
<br>
<script text="javascript">
 document.write(document.img1.src + "<br>");
 document.write(document.img1.name + "<br>");
 document.write(document.img1.width + "<br>");
 document.write(document.img1.height + "<br>");
</script>
</body>
</html>
 
위 처럼 img 태그 안의 name을 자바스크립트 안에서 document."이름" 으로 속성 등을 사용할 수 있다.
또한 document.images.length와 같이 document안의 이미지들의 개수 등을 구해줄 수도 있다.

 

* history 객체
history객체 역시 많이 이용하는 객체중에 하나로 보통은 전/후 단계로의 이동을 해주며,

 

//아래 두개는 같은 의미를 갖는다.
history.back()
history.go(-1)
 
length : 히스토리 안에 있는 url의 개수
back() : 전 단계로 이동
forward() : 히스토리 한 단계 앞으로 이동
go(): 히스토리에서 원하는 위치로 이동

 

* location 객체
문서에 대한 정보 프로토콜, 호스트 이름, 포트, 디렉토리, 파일 이름 등의 정보를 가지고 있다.
속성: href, host, hostname, protocol, pathname, port, hash, search
메소드: reload()-현재 페이지 재로드, replace()-현재 페이지를 원하는 페이지로 변경

 

<html>
<head>

</head>
<body onclick="bgcol('pink','blue')">
<br>
<script text="javascript">
 function rel(){
  location.reload();
 }
</script>
<input type="button" onclick="rel()" value="click">
</body>
</html>

 

 

 

 

직장을 다니면서 투잡(알바/부업)으로 월급 많큼 수익을 얻고 싶으시다면  

아래 접속하셔서 상담받아 보실 수 있습니다. (믿음의 재택부업회사)

 

블로그 이미지

itworldkorea

IT korea가 세상(world)을 변화시킨다.

,