Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- 리덕스
- 자바스크립트
- dfs
- 알고리즘
- 기지국 설치 자바스크립트
- 백준 2638번
- 기지국 설치 js
- 부녀회장이 될 테야
- 2275번
- 1937번 욕심쟁이 판다
- ssh
- 힙 자바스크립트
- 백준 1068
- Java
- 프로그래머스
- 24480번
- React
- 우선순위 큐 자바스크립트
- level1
- 백준 13023번
- Redux
- 1303번
- JavaScript
- 백준
- 13023번 ABCDE
- 2638번 치즈
- 백준 1068번 트리
- 알고리즘 수업-깊이 우선 탐색1
- 1389번 케빈 베이컨의 6단계 법칙
- level0
Archives
- Today
- Total
코딩왕랄프👊🏻
[Javascript] Browser BOM 본문
반응형
SMALL
Browser BOM
Javascript Browser Object Models
# Window
: 브라우저의 window를 나타냄
=> JavaScript objects, 함수, 변수들이 window object의 멤버가 됨.
size
=> window.innerHeight
=> window. innerWidth
Methods
=> window.open()
=> window.close()
=> window.moveTo()
=> window.resizeTo()
# Screen
Property
screen.width
screen.height
screen.availWidth : visitor 스크린의 넓이 리턴
screen.availHeight : visitor 스크린의 높이 리턴
screen.colorDepth : 한 컬러를 나타내는데 사용되는 bit 수
screen.pixelDepth : pixel depth 리턴
# Location
Property
window.location.href : 현재 페이지 URL
window.location.hostname : 웹 호스트의 domain 이름
window.location.pathname : 현재 페이지 경로와 파일이름
window.location.protocol : 웹 프로토콜
window.location.assign() : 새로운 문서 로드
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript</h2>
<h3>The window.location object</h3>
<p id="demo1"></p>
<p id="demo2"></p>
<p id="demo3"></p>
<p id="demo4"></p>
<p id="demo5"></p>
<input type="button" value="Load new document" onclick="newDoc()">
<script>
document.getElementById("demo1").innerHTML =
"The full URL of this page is:<br>" + window.location.href;
document.getElementById("demo2").innerHTML =
"Page hostname is: " + window.location.hostname;
document.getElementById("demo3").innerHTML =
"Page path is: " + window.location.pathname;
document.getElementById("demo4").innerHTML =
"Page protocol is " + window.location.protocol;
document.getElementById("demo5").innerHTML =
"Port number is " + window.location.port;
function newDoc() {
window.location.assign("https://www.w3schools.com")
}
</script>
</body>
</html>
# History
Method
history.back() : clicking back in the browser
history.forward() : clicking forward in the browser
<html>
<head>
<script>
function goBack() {
window.history.back()
}
</script>
</head>
<body>
<input type="button" value="Back" onclick="goBack()">
</body>
</html>
# Navigator
navigator.appName
navigator.appCodeName
navigator.platform
Browser Cookies
=> cookieEnabled : cookies가 enable 하면 true
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"cookiesEnabled is " + navigator.cookieEnabled;
</script>
Browser Cookies
=> cookieEnabled : cookies가 enable 하면 true
Browser Application Name
=> appName : application 이름
Browser Application Code Name
=> appCodeName : application 코드 name
Browser Engine
=> product : 브라우저 엔진의 product name
Browser Version
=> appVersion : 브라우저 관한 버전 정보
Browser Agent
=> userAgent : 브라우저에서 서버로 보내지는 user-agent header
# Popup Alert
Alert Box
=> information을 make sure 하길 원할때
=> alert box가 팝업 -> OK 클릭
window.alert("sometext");
Confirm Box
=> 어떤 것을 verify/accept 하길 원할때
=> alert box가 팝업 -> OK/Cancel 클릭
window.confirm("sometext");
Prompt Box
=> 페이지를 들어가기 전에 value를 input 하기 원할때
=> alert box가 팝업 -> OK/Cancel 클릭
window.prompt("sometext","defaultText");
# Timing Events
Methods
=> setTimeout()
=> setInterval()
setTimeout()
window.setTimeout(function, milliseconds);
clearTimeout()
window.clearTimeout(timeoutVariable)
setInterval()
window.setInterval(function, milliseconds);
반응형
LIST