Created
May 17, 2010 23:30
-
-
Save rwaldron/404377 to your computer and use it in GitHub Desktop.
This file contains 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> | |
<head> | |
<title>Workers: Basic Demo</title> | |
<script> | |
document.addEventListener('DOMContentLoaded', function () { | |
var worker = new Worker('worker-javascript-file.js'); | |
worker.postMessage('Hello Worker!'); | |
worker.addEventListener('message', function (event) { | |
console.log(event.data); // will log "Hello Main Window!" | |
}, false); | |
}, false); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains 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
self.addEventListener('message', function (event) { | |
this.postMessage( event.data.replace('Worker', 'Main Window') ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Won't it output Hello Main Window!?