korean IT student

javascript-BOM이란 본문

front-end/Javascript, jQuery

javascript-BOM이란

현창이 2017. 11. 8. 13:20

BOM(Browser Object Model)

웹브라우저의 창이나 프레임을 추상화해서 프로그래밍적으로 제어할 수 있도록 제공하는 수단이다. 


전역객체 Window

window.alert =alert //window란 전역객체



사용자와 커뮤니케이션 하기

alert('')


confirm('ok?')  - true or false 실행


예제)


<input type="button" value="confirm" onclick ="func()"/>

<script>

  function func(){

     if(confirm('ok?')){

          alert('ok);

       } else{

           alert('cancel');

       }

   }

</script>


prompt - 사용자가 입력한 값을 받아서 자바스크립트가 얻어낼수있는 기능


Location 객체

문서의 주소와 관련된 객체로 window 객체의 프로퍼티다. 이 객체를 이용해서 원도우의 문서 URL을 변경할 수 있고, 문서의 위치와 관련해서 다양한 정보를 얻을 수 있다.

console.log(location.toString(), location.href(); -현재 url값

console.log(location)-객체 값

alert(location); -객체의 문자화된 결과를 보여줌 현재url = alert(location.toString()); , href


location.href ='www.naver.com';


Navigator 객체

-브라우저의 정보를 제공하는 객체다. 주로 호환성 문제등을 위해서 사용한다.

console.dir(navigator);

console.dir(navigator.appName); -웹브라우저의 이름이다. IE는 Microsoft Internet Explorer, 파이어폭스, 크롬등을 Nescape로 표시한다.

console.dir(navigator.appVersion);- 브라우저의 버전을 의미

navigator.platform -브라우저가 동작하고 있는 운영체제에 대한 정보



크로스브라우징이란?

html, css, 그리고 javascript 작성시 W3C 의 web standard (웹규격) 에 맞는 코딩을 함으로써 어느 브라우져에서나 기기에서 사이트가 제대로 보여지고 작동되도록 하는 기법을 말합니다.


창 제어

window.open('demo.html'); 새 창이 만들어진다.

window.open('demo.html','_blank'); _blank는 새창을  의미한다.



'front-end > Javascript, jQuery' 카테고리의 다른 글

jQuery- 요소 삽입하기  (0) 2018.01.08
javascript-전역 객체(String)에 대해  (0) 2017.12.31
javascript-Node객체란  (0) 2017.11.11
javascript-Element객체란  (0) 2017.11.08
javascript-DOM이란  (0) 2017.11.08
Comments