Cannot create inline web workers using BLOB-URL in IE11. Works fine in Edge, Firefox, Chrome. (All browsers are up-to-date.)
For example below JavaScript code fails to create web worker.
try{
var blob = new Blob(["(" + function1.toString() + ")(" + parametersJSON + ")"], {type: 'application/javascript'});
var x = window.URL.createObjectURL(blob);
var worker = new Worker(x);
} catch(err){
console.log(err);// displays "invalid function" in IE11.
}
Any help?
Is there any other alternative? to achieve the goal of creating a web worker from a string without using the external file? (Should work in InternetExplorer 11+)
Full code is as follows:
<html>
<head>
<title>Web Worker Test</title>
<script>
function function1(parametersJSON){
console.log(parametersJSON.testKey1);
}
try{
var parametersJSON = {'testKey1':'foo','testKey2':'bar'};
var parametersJSONString = JSON.stringify(parametersJSON);
var blob = new Blob(["(" + function1.toString() + ")(" + parametersJSONString + ")"], {type: 'application/javascript'});
var x = window.URL.createObjectURL(blob);
var worker = new Worker(x);
} catch(err){
console.log(err);// displays "invalid function" in IE11.
}
</script>
</head>
<body>
Test
</body>
</html>