Created
August 26, 2011 08:35
-
-
Save tango238/1172990 to your computer and use it in GitHub Desktop.
[HTML5] No WebWorkers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>No WebWorkers</title> | |
</head> | |
<body> | |
<section id="wrapper"> | |
<header> | |
<h1>No WebWorkers</h1> | |
</header> | |
<article> | |
Input Number:<input type="text" id="num" value="1000000000"> | |
<button id="btnCalc">Calculate</button> | |
</article> | |
<script> | |
(function(){ | |
var btnCalc = document.getElementById('btnCalc'); | |
btnCalc.onclick = function(){ | |
// 取得した値をintに変換 | |
var num = parseInt(document.getElementById('num').value); | |
var result = 0; | |
// ループで合計を計算 | |
for (var i = 0; i <= num; i++) { | |
result += i; | |
} | |
alert("Sum:" + result); | |
}; | |
})(); | |
</script> | |
</section> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment