-
Book Overview & Buying
-
Table Of Contents
HTML5 Web Application Development By Example : Beginner's guide
By :
Debugging web workers can be difficult. You don't have access to the window object so you can't call alert() to display a message or console.log() to write out to the browser's JavaScript console. You can't write out a message to the DOM either. You can't even attach a debugger and step through the code. So what's a poor developer to do?
One thing you can do is add an error listener to the worker, so you get notified of any errors inside the worker's thread:
worker.addEventListener("error", function(e)
{
alert("Error in worker: " + e.filename + ", line:" + e.lineno + ", " + e.message);
});The event object passed into the error handler contains the filename, lineno, and message fields. From those you can tell exactly where an error happened.
But what if you aren't getting an error, things just aren't working right? First of all, I recommend that you keep the code that does all of the...
Change the font size
Change margin width
Change background colour