1

I am trying to implement a 'web Workerto resolve a problem. However whenever I try to test theWorker` to see if it exists, I keep getting back that Worker is 'undefined'.

Environment: Window 7.0, Visual Studio 2013, Internet Explorer 11, HTML 5. Application is MVC.

csHTML (I have substituted actual URLs and anchor text with generic square brackets "[ ]" for the sample code):

<a class="document-link" onclick="markLastVisitedCaseDocument([url]);
 openDocument([url])">[anchor text]</a>

So the onclick event fires two JavaScript functions. The first marks that the text was recently visited. The second (and the one I am having trouble with) opened the URL (which is a PDF document) in a PDF editor on the client. This works, but in production can take an extraordinary amount of time. I have been asked to implement a "please wait" message. However as JavaScript is single threaded I didn't see how to implement a 'wait' message and bring up the editor and document.

In my research I came upon two options: Web Worker (window.Worker) or HTML5 (which I believe allows multithreading of JavaScript). I would rather not implement HTML5 at this time given a limited time window for this fix. I have been trying to implement window.Worker, but keep getting notice that it is 'undefined'.

At the moment I am just trying to get the Worker to 'work'. The code gives me the error that Worker is undefined.

function openDocument(url) {
    var myWorker = new Worker("Worker.js);

This is not equivalent to [Are Shared WebWorkers supported in IE 11? as that user was trying to use Shared Web Workers and I am trying to use Web Workers. That user also accepted as best answer that Shared Web Workers are not supported in IE. I have read that Web Workers are supposedly supported.

crmauch
  • 21
  • 4
  • Possible duplicate of [Is WebWorkers supported in IE 11?](https://stackoverflow.com/questions/44708277/is-webworkers-supported-in-ie-11) – Jared Smith Sep 05 '18 at 18:58
  • I don't believe this is a duplicate as I am not attempting to use shared server workers. – crmauch Sep 05 '18 at 20:44
  • 1
    It is a duplicate: `window.Worker` is the web worker constructor. It has nothing to do with "shared server workers", whatever those are. – Jared Smith Sep 05 '18 at 23:22
  • As for why it's undefined, well, IDK, it should be. What are you assigning to `self`? That's usually only used in JavaScript *inside* a worker. – Jared Smith Sep 05 '18 at 23:29
  • As I have understood it there are Web Workers and Shared Web Workers. If you read the other post the user was trying to user Shared Web Workers. I do apologize for inaccurately putting in the word 'Server'. – crmauch Sep 06 '18 at 13:24
  • self is functionally equivalent from my reading to window, but I have corrected the code to be window.Worker – crmauch Sep 06 '18 at 13:26
  • `window.Worker` *should* be defined in IE 10+, so I think your question has merit (I've removed my downvote). So which type of worker do you want? Web Worker (i.e. window.Worker)? Service worker (not supported)? Shared worker (not supported)? – Jared Smith Sep 06 '18 at 13:36
  • Do you have any plugin on your browser? Can you reproduce on any page or a single one? If the latter, do you have a `X-UA-Compatible` meta tag on this page? If not, does the same issue appears when you remove all script tags? If it does, re-add them one by one and check which one should be fired. – Kaiido Sep 07 '18 at 05:16

0 Answers0