![]() |
Now that we have the web worker file, we need to call it from an HTML page. The following lines checks if the worker already exists, if not - it creates a new web worker object and runs the code in "script.js": |
if (typeof(w) == "undefined") {
w = new Worker("script.js");
}
w.onmessage = function(event){
document.getElementById("result").innerHTML = event.data;
};
What is HTML Web Workers API | HTML Web Workers API |
What types of browsers will support | HTML Web Workers API |
How to work a HTML Web Workers | HTML Web Workers API |
How to check Web Worker Support | HTML Web Workers API |
How to create HTML Web Worker File | HTML Web Workers API |
How to Create a Web Worker Object | HTML Web Workers API |
How to Terminate a Web Worker | HTML Web Workers API |
How to Reuse the Web Worker | HTML Web Workers API |
Full Web Worker Example Code | HTML Web Workers API |
What is Web Workers and the DOM | HTML Web Workers API |
Read Full: | HTML Web Workers API |
Category: | Web Tutorial |
Sub Category: | HTML Web Workers API |
Uploaded: | 1 year ago |
Uploaded by: | Admin |
Views: | 57 |
Reffered: https://www.w3schools.com/html/html5_webworkers.asp