hyunjin

javascript3 본문

SISS/웹

javascript3

_h.j 2019. 2. 10. 19:03
728x90

 

 

 

•브라우저 객체

-javascript에서 웹브라우저와 관련된 객체를 브라우저 객체

 

•window 객체 : 브라우저 창 제어

 

•open() : 창 새로 열 때 사용하는 메소드

window.open( [url주소], [창 이름], [창 속성]  )

 

-클릭 이벤트를 이용해 창을 닫는 예제

window.open("open.html", "" , toolbar=no location=no status=no menubar=no scrollbar=no width=200 height=400")

<form><input type = "button" value = "Close" onclick = "window.close()"></from>

 

 

•setTimeout() : 타이머 메소드

-정해진 시잔 뒤에 javasript의 함수 실행위해 사용하는 함수

•setInterval() : 반복 타이머 메소드

•clearTimeout() : 타이머 중지 메소드

-setTimeout()메소드가 반환하는 값을 변수로 지정해 놓고 clearTimeout 실행하면 setTimeout() 메소드 더 이상 동작 안함

•clearInterval()

 

예제

Stop 누르면 시계가 멈춘다.

 

버튼 삽입은

<form>
  <input type = "button" value = "Stop!" onclick = "clearInterval(CLOCK)">
 </form>

 

이런 방식으로.... 이뤄지나보다

 

 

-open메소드 실행했던 창을 부모창, 새로 열린 창을 자식 창

-자식 창에서 부모 창 컨트롤 가능(이를 위해 opener객체 사용)

 

 

•자식 창에서 부모창 닫는 예제

-부모창 :

<html>

<body onload = "window.open('popup.html', '', 'toolbar=no resizable=no width=200 height=400')">

</body>

</html>

-popup.html 창 :

<html>

<body>

<form>

<input type = "button" value = "부모창 닫기" onclick = "opener.close()">

</form>

</body>

</html>

 

 

 

•window.parent : 프레임이 나눠져 있는 환경에서 현재 프레임의 상위 프레임 지칭 객체

•frames[] : 상위프레임에서 하위 프레임 지칭 객체

-이름 이용하는 방법도 있음

<frameset rows = "20%, 70%, *"> 

<frame src = "f1.html" name = "AAA"> 

<frame src = "f2.html" name = "BBB"> 

<frame src = "f3.html" name = "CCC">

</frameset>

 

<html>
  <head><script language = "javascript">
 function changeBgColor(color){
  window.parent.frames[1].document.bgColor = color
 }
  </script>
  </head>
  <body>
  <form>
  <input type="button" value="Violet" onclick="changeBgColor('pink')">
  <input type="button" value="Blue" onclick="changeBgColor('blue')">
  </form></body>
</html>
-> 완성된 코드 아님!!

 

이런 식으로 지정한 프레임의 bgcolor 바꿀 수 있음.

 

 

•history 객체 : 최근 방문한 주소를 기억하고 있는 객체(뒤로가기 버튼 같은 것에 사용)

페이지들은 모두 history 객체에 저장

- history.length: 히스토리의 개수

- history.back(): 뒤로가기

- history.forward(): 앞으로가기

- history.go([숫자]): 뒤로가기 버튼을 [숫자]만큼 누른 것과 같은 효과.

음 수를 입력 시 앞으로가기 효과를 낸다.

 

•navigator : 브라우저 정보 제공

document.write("<p>Browser Name: " + navigator.appName + "</p>")  이런 식으로 사용

 

 

 

 

 

728x90

'SISS > ' 카테고리의 다른 글

  (0) 2019.03.03
웹3-2  (0) 2019.02.17
javascript2  (0) 2019.02.03
웹 javascript1  (0) 2019.01.27