일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 페이지분석
- DoIt
- 함수 선언
- 웹 브라우저 전쟁
- dbms
- 키-값 데이터베이스
- 우아한테크
- DoitSQL
- 예제
- R1C3
- 배열 예제
- 생성자
- 숫자형식오류
- html
- 숫자 형식
- Doit입문SQL
- 웹브라우저 수용도
- 함수
- SQL
- HTML역사
- 데이터베이스
- 배열 3요소
- SQL입문
- 크롤링
- DoitSQL입문
- 자바 오류
- 자바
- 예외
- 자바 예외
- 크롤링 오류
Archives
- Today
- Total
반응형
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 페이지분석
- DoIt
- 함수 선언
- 웹 브라우저 전쟁
- dbms
- 키-값 데이터베이스
- 우아한테크
- DoitSQL
- 예제
- R1C3
- 배열 예제
- 생성자
- 숫자형식오류
- html
- 숫자 형식
- Doit입문SQL
- 웹브라우저 수용도
- 함수
- SQL
- HTML역사
- 데이터베이스
- 배열 3요소
- SQL입문
- 크롤링
- DoitSQL입문
- 자바 오류
- 자바
- 예외
- 자바 예외
- 크롤링 오류
Archives
- Today
- Total
프로그래밍
[Web] day35 : BOM (Browser Object Model) 본문
728x90
반응형
2023.06.23.금
BOM (Browser Object Model)
웹에서 기본 제공해주는 다양한 객체이다
대부분의 브라우저에서 구현은 되어있지만, 정의된 표준이 없어 브라우저 제작사 마다 세부사항이 다르고 다소 한정적이라는 특징이 있다
BOM 객체를 통해 웹 브라우저의 버튼, URL 주소 입력 창, 타이틀 바 등 웹브라우저 윈도우 및 웹페이지의 일부분을 보다 쉽게 제어할수 있게 된다
history 객체
현재의 브라우저가 접근했던 URL history에 대한 객체이다
BOM : history 객체
다음
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>웹에서 기본 제공해주는 다양한 객체 == BOM</title>
</head>
<body>
<h1>BOM : history 객체</h1>
<hr>
<a href ="test08.html">다음</a>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>결과 페이지</title>
</head>
<body>
<input type="button" value ="뒤로가기 버튼">
<script type="text/javascript">
var obj = document.querySelector('input');
obj.onclick = function(){
//history.back();
history.go(-1);
}
</script>
</body>
</html>
window 객체
Global Context, 브라우저 창 객체이다
BOM : window 객체
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>웹에서 기본 제공해주는 다양한 객체 == BOM</title>
</head>
<body>
<h1>BOM : window 객체</h1>
<hr>
<button type="button">새 창 열기</button>
<button type="button">창 닫기</button>
<script type="text/javascript">
var btnArr = document.querySelectorAll('button');
btnArr[0].addEventListener('click', openWindow);
btnArr[1].addEventListener('click', closeWindow);
function openWindow() {
var newWindow = window.open('', '팝업창', 'width=400, height=300');
newWindow.document.write('<h1>새 창 열기</h1>');
}
function closeWindow() {
if (newWindow != undefined)
newWindow.close();
}
</script>
</body>
</html>
활용 예제
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="#" name="loginForm">
<table border="1">
<tr>
<td>아이디</td>
<td><input type="text" class="login" name = "memberId" placeholder="5자 이상"
required></td>
</tr>
<tr>
<td>비밀번호</td>
<td><input type="password" class="login" name = "passwd" placeholder="10자 이상"
required></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="데이터전송"></td>
</tr>
</table>
</form>
<script type="text/javascript">
var elem = document.forms.loginForm;
// var elem = document.forms['loginForm'];
elem.onsubmit = function(){
if(this.memberId.value.length < 5) {
alert('아이디는 5자 이상이어야 합니다');
this.memberId.focus();
return false;
}
if(this.passwd.value.length < 10) {
alert('비밀번호는 10자 이상이어야 합니다');
this.passwd.focus();
return false;
}
}
var arr = document.querySelectorAll('.login');
for (var i = 0; i < arr.length; i++) {
arr[i].onfocus = function() {
this.style.backgroundColor = 'lightblue';
}
arr[i].onblur = function() {
this.style.backgroundColor = 'white';
}
}
</script>
</body>
</html>
728x90
반응형
'Web > Web' 카테고리의 다른 글
[Web] day36 : jQuery 자바스크립트 라이브러리 (1) | 2023.07.05 |
---|---|
[Web] day36 : 자바스크립트 주사위/가위바위보 예제 (0) | 2023.07.04 |
[Web] day35 : 자바스크립트 이벤트 활용 예제 (0) | 2023.07.04 |
[Web] day35 : 자바스크립트 이벤트 연결02 (0) | 2023.07.04 |
[Web] day34 : 자바스크립트 이벤트 연결01 (0) | 2023.07.04 |
Comments