event.timeStamp 정보
jQuery event.timeStamp본문
event.timeStamp
설명 : 브라우저가 이벤트를 만든 시간과 1970 년 1 월 1 일 사이의 시간 차이 (밀리 초)입니다.
이 등록 정보는 event.timeStamp코드의 두 지점에서 값을 가져 와서 차이점 을 알면 이벤트 성능을 프로파일 링하는 데 유용 할 수 있습니다 . 이벤트 처리기 내에서 현재 시간을 간단하게 결정하려면 (new Date).getTime()대신에를 사용하십시오.
참고 : 2004 년부터 버그가 열려 있기 때문에이 값은 Firefox에서 올바르게 채워지지 않으므로 해당 브라우저에서 이벤트가 생성 된 시간을 알 수 없습니다.
예:
클릭 핸들러가 마지막으로 실행 된 이후의 시간을 표시합니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>event.timeStamp demo</title>
<style>
div {
height: 100px;
width: 300px;
margin: 10px;
background-color: #ffd;
overflow: auto;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div>Click.</div>
<script>
var last, diff;
$( "div" ).click(function( event ) {
if ( last ) {
diff = event.timeStamp - last;
$( "div" ).append( "time since last event: " + diff + "<br>" );
} else {
$( "div" ).append( "Click again.<br>" );
}
last = event.timeStamp;
});
</script>
</body>
</html>
0
댓글 0개