Created
November 29, 2011 11:34
-
-
Save deanhume/1404507 to your computer and use it in GitHub Desktop.
HTML5 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
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> | |
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Web Worker Example</title> | |
<script src="<%= Url.Content("~/scripts/modernizr-1.7.min.js") %>"></script> | |
</head> | |
<body> | |
<p>Result: <output id="result"></output></p> | |
<script> | |
if (Modernizr.webworkers) { | |
var worker = new Worker('<%= Url.Content("~/scripts/LogStats.js") %>'); | |
worker.onmessage = function (event) { | |
document.getElementById('result').textContent = event.data; | |
}; | |
worker.onerror = function (event) { | |
console.log(event.message, event); | |
}; | |
} else { | |
alert("Sorry!! you do not have web workers support."); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment