메뉴 건너뛰기

관리자2020.09.14 16:37
다음 코드를 이용해보세요. 잘됩니다.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title></title>
<style></style>
<script></script>
</head>
<body>
<h2>타이머</h2>
<hr>
<span id="timer">타이머 카운트</span><br>
<button type="button" id="start" onclick="start(event)">start</button>
<button type="button" id="stop" onclick="stop(event)">stop</button>
<script>
var worker = null;
var span = document.getElementById("timer");

function start(e) {
if (worker != null)
return;
else{
worker = new Worker("timer.js");
worker.onmessage = function (e) {
span.innerHTML = e.data;
}
worker.postMessage("start");
}
}
function stop(e) {
worker.postMessage("stop");
worker = null;
}
</script>
</body>
</html>
파일 첨부

여기에 파일을 끌어 놓거나 파일 첨부 버튼을 클릭하세요.

파일 크기 제한 : 0MB (허용 확장자 : *.*)

0개 첨부 됨 ( / )
위로