K
K
Keyten2012-04-16 19:31:28
JavaScript
Keyten, 2012-04-16 19:31:28

Data:URL Web Workers

You need to make sure that arbitrary js code is loaded inside the web worker. I took data: url, did something like this:

var w = new Worker('data:text/javascript;,' + content);

Everything is fine in firelis, but in chrome [chromium] it throws out SECURITY_ERR. Tell me what to do?

PS: I have a little old chromium here, maybe this is the case? Check plz.
PPS: if that's not the case, I remember there was an article on html5rocks that mentioned BlobBuilder for this purpose.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
demark, 2012-04-16
@Keyten

var worker = new Worker(
    window.URL.createObjectURL(
        new BlobBuilder().append(
            "onmessage = function(e) { postMessage('hello habrahabr'); }"
        ).getBlob()
    )
);

worker.postMessage();

www.html5rocks.com/en/tutorials/workers/basics/#toc-inlineworkers

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question