Window.alert on the working branch
If I put window.alert on the webmaster client, the background worker stops working. Why is this so?
i.e. Defiant:
var worker = new Worker("worker.js");
// Watch for messages from the worker
worker.onmessage = function(e){
// The message from the client:
e.data
};
worker.postMessage("start");
Client (worker.js)
onmessage = function(e){
if ( e.data === "start" ) {
// Do some computation
done()
}
};
function done(){
alert('don'); // ===> This kills the worker.
// Send back the results to the parent page
postMessage("done");
}
+2
source to share
3 answers
You noticed that the warning hangs on the javascript engine until the user types OK.
If you don't want it to freeze, don't use warnings.
For debugging with firebug:
console.log("bla bla bla");
For non-blocking pop-ups:
create a hidden div with ok button. When the popup appears. Make the div visible. When the user clicks "ok", hide it.
I would advise you not to use pop-ups. It also disrupts the "workflow" (which means user concentration) of the user behind the screen :)
0
source to share