JavaScript
16장 마무리 문제 2
쥬크버그
2023. 4. 12. 17:43
<!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객체를 반환