1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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);