mardi 22 mars 2016

Access window object from a different js file

I have a web worker that generates pdf of a table and post it on the main js file. The code is something like this

worker.js

onmessage = function(e) {
    var pdf = window.generatePdf();
    postMessage(e.data[0]);
}

main.js

var worker = new Worker('worker.js');
worker.postMessage([config]);
worker.onmessage = function(e) {
  save(e.data);
}

But window object can no be accessed in worker.js file. Any idea on how to make it accessible in that file or how to achieve the functionality otherwise. Thaks




Aucun commentaire:

Enregistrer un commentaire