What's the best way to know if the running browser supports web-workers ?
is it
try { new Worker(); } catch (e) { /* it does not */ }
Thanks
This is the code the script Modernizr uses:
tests[webWorkers] = function () {
return !!window.Worker;
};
You can try window.Worker
in your browser's console to check if the function exists. In your javascript code you can try this:
if (typeof(Worker) !== "undefined") {
//great, your browser supports web workers
} else {
//not supported
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.