<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>현재 시각</title>
<style>
#container {
width:200px;
margin:50px auto;
}
button {
border:1px solid #ccc;
background:#fff;
padding:20px 30px;
}
</style>
<body>
<div id="container">
<button id="bttn">현재 시간 보기</button>
</div>
<script>
document.getElementById('bttn').onclick = displayTime;
function displayTime() {
var left = (screen.availwidth - 400)/2;
var top = (screen.availHeight - 200)/2;
var opt = "left=" + left + ",top=" + top + ",width=" + 400+ ",height="+ 200;
window.open("practice1.html","",opt);
}
</script>
</body>
</html>
- Document.getElementById(id)
: 주어진 문자열과 일치하는 id 속성을 가진 요소를 찾고, 이를 나타내는 Element객체를 반환
'JavaScript' 카테고리의 다른 글
17장 예제 - DOM 요소에 접근하고 속성 가져오기(1) (0) | 2023.04.13 |
---|---|
17장 예제 - 문서객체모델 (DOM) 알아보기 (0) | 2023.04.12 |
16장 마무리 문제 1 (0) | 2023.04.12 |
16장 실습 4 (0) | 2023.04.11 |
16장 실습 3 (0) | 2023.04.11 |