在HTML5中使用Web Worker记录错误以控制台进行控制台
这是WebWorkerJavaScript文件中将错误记录到控制台的错误处理功能的示例。
示例
使用错误处理代码,上面的示例将如下所示:
<!DOCTYPE HTML> <html> <head> <title>Big for loop</title> <script> var worker = new Worker('bigLoop.js'); worker.onmessage = function (event) { alert("Completed " + event.data + "iterations" ); }; worker.onerror = function (event) { console.log(event.message, event); }; function sayHello(){ alert("Hello sir...." ); } </script> </head> <body> <input type = "button" onclick = "sayHello();" value = "Say Hello"/> </body> </html>