티스토리 뷰
Window Object Properties
document Returns the Document object for the window (See Document object)
location Returns the Location object for the window (See Location object)
Location Object Methods
assign() Loads a new document (history정보가 보존된 상태로...)
reload() Reloads the current document
replace() Replaces the current document with a new one(history정보가 삭제된 상태로...)
opener Returns a reference to the window that created the window
parent Returns the parent window of the current window
Window Object Methods
setTimeout() Calls a function or evaluates an expression after a specified number of milliseconds
clearTimeout() Clears a timer set with setTimeout()
moveBy() Moves a window relative to its current position
moveTo() Moves a window to the specified position
print() Prints the content of the current window
resizeBy() Resizes the window by the specified pixels
resizeTo() Resizes the window to the specified width and height
scrollBy() Scrolls the content by the specified number of pixels
scrollTo() Scrolls the content to the specified coordinates
scollBy(), scrollTo()을 이용하여 게시판 글을 읽고 다시 목록으로 왔을대 사용자가 클릭한 위치에
스크롤의 위치를 정해줄 수 있다 이렇게 함으로서 사용자는 처음부터 다시 스크롤을 내릴필요가 없다.
setInterval() Calls a function or evaluates an expression at specified intervals (in milliseconds)
setTimeout()은 이벤트가 발생한 시점을 기준으로 정해준 시간 이후에 실행되지만
setInterval()은 이벤트가 발생한 즉시 정해준 시간 간격으로 실행된다.
이외에도 Window Object에는 많은 Properties, Methods등이 있다. 자세한 내용은 참조사이트를 확인하기 바란다.
setTimeout() & clearTimeout()의 좋은 예제
<!doctype html>
<html>
<head>
<script type="text/javascript">
var c=0;
var t;
var timer_is_on=0;
function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
t=setTimeout("timedCount()",1000);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount();
}
}
function stopCount()
{
clearTimeout(t);
timer_is_on=0;
}
</script>
</head>
<body>
<form>
<input type="button" value="Start count!" onclick="doTimer()" />
<input type="text" id="txt" />
<input type="button" value="Stop count!" onclick="stopCount()" />
</form>
</body>
</html>
비고
alert(), blur(), close(), focus(), open()... 이러한 Methods 모두 Window Object Methods 이다.
일상적으로 우리가 window.* 선언을 생략할 뿐이다.
자료 출처
Window Object : http://www.w3schools.com/jsref/obj_window.asp
Location Object : http://www.w3schools.com/jsref/obj_location.asp
- Total
- Today
- Yesterday
- hyper-v
- mssql
- 공백제거
- trim
- 제품 등록
- System.Diagnostics
- 문자 자르기
- async
- 특정 문자를 기준으로 자르기
- 상품 등록
- 진수 변환
- await
- MainActor
- App Store
- html tag
- system.io
- .submit()
- nl2br
- 아이폰
- In App Purchase
- 명령어
- 앱 스토어
- FileUpload
- Task
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |