|
|
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;
}; Category: | Web Tutorial |
Sub Category: | HTML Web Workers API |
Uploaded by: | Admin |
Read Articlehttps://develop.horje.com/learn/1434/reference