- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Log error to console with Web Workers in HTML5
Here is an example of an error handling function in a Web Worker JavaScript file that logs errors to the console.
Example
With error handling code, above example would become like the following:
<!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>
- Related Articles
- Stop Web Workers in HTML5
- How to handle errors in HTML5 Web Workers?
- Why HTML5 Web Workers are useful?
- How can I use Web Workers in HTML5?
- How to check web browser support in HTML5
- Use of Ionic as desktop web application with HTML5
- Html5 responsiveness of the web
- How to allow the restricted resources from another domain in web browser with HTML5
- How to get Exception log from a console and write it to external file in java?
- How do I print a message to the error console using JavaScript?
- How to display HTML5 client-side validation error bubbles?
- What is meant by HTML5 Web Messaging?
- Does HTML5 allow you to interact with local client files from within a web browser?
- Using HTML5 Server-Sent Events in a web application
- Error while calling Web Service using SRT_UTIL Transaction

Advertisements