Skip to content

Instantly share code, notes, and snippets.

@tango238
Created August 26, 2011 08:35
Show Gist options
  • Save tango238/1172990 to your computer and use it in GitHub Desktop.
Save tango238/1172990 to your computer and use it in GitHub Desktop.
[HTML5] No WebWorkers
<!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