Skip to content

Instantly share code, notes, and snippets.

@fillano
Created November 7, 2010 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fillano/666107 to your computer and use it in GitHub Desktop.
Save fillano/666107 to your computer and use it in GitHub Desktop.
detect DedicatedWorker global scope and report to js in html
onmessage = function(global) {
return function(e) {
if(e.data.indexOf('start') > -1) {
var str = '<table width="100%" border="1" cellspacing="0" cellpadding="2">\n';
for (var i in global) {
if(i!=='onmessage') {
str += '<tr><td style="background: #AABBCC">' + i + '</td><td style="background: #DDEEFF">' + global[i] + '</td></tr>\n';
} else {
str += '<tr><td style="background: #AABBCC">' + i + '</td><td style="background: #DDEEFF">onmessage eventHandler</td></tr>\n';
}
}
str += '</table>\n';
global.postMessage(str);
}
};
}(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment