Do Web Workers Work In FF v43?
I have the following html page:
<!DOCTYPE HTML> <html> <head> <title>Web Worker Example</title> </head> <body> <p>The time is now: <span id="result" /></p> <script> var worker = new Worker('worker.js'); worker.onmessage = function (event) { document.getElementById('result').innerText = event.data; }; </script> </body> </html>
And the worker.js is simply:
setInterval(function() { postMessage(new Date()); }, 2000);
This works fine in Chrome but I get nothing after "The Time Is Now:" in FireFox?
Ideas?
Thanks,
Ray
Geändert am
Alle Antworten (6)
I just noticed my initial post got all jacked up!
Here is the html:
<title>Web Worker example</title>
The time is now:
<script> var worker = new Worker('worker.js'); worker.onmessage = function (event) { document.getElementById('result').innerText = event.data; }; </script>And worker.js:
setInterval(function() {
postMessage(new Date());
}, 2000);
Again, this works in Chrome but not FireFox.
Wow...hozed again? Why can't I copy and paste into this window?
rayj00 said
I just noticed my initial post got all jacked up! Here is the html: <title>Web Worker example</title>The time is now:
<script> var worker = new Worker('worker.js'); worker.onmessage = function (event) { document.getElementById('result').innerText = event.data; }; </script> And worker.js: setInterval(function() { postMessage(new Date()); }, 2000); Again, this works in Chrome but not FireFox.
Forget it. This sucks!
I've fixed your first question post.
Try to ask advice at the Stack Overflow forum site.
cor-el said
I've fixed your first question post.
Try to ask advice at the Stack Overflow forum site.
I did post to Stack Overflow. So far no responses. This should not be that hard of a question. I'm pretty sure this should work in FF. I just don't know if I need to set something in about:config or not?
Thanks for fixing it. What was the issue? You can't cut and paste?
Ray
Current Firefox versions do not support innerText, so you need to use innerHTML to make it work in Firefox. The code will work in Firefox 45 and later.
- Bug 264412 - (innertext) Add support for element.innerText (45+)
data:text/html;charset=utf-8;base64,PCFET0NUWVBFIEhUTUw+CjxodG1sPgogIDxoZWFkPgogICAgPHRpdGxlPldlYiBXb3JrZXIgRXhhbXBsZTwvdGl0bGU+CiAgPC9oZWFkPgogPGJvZHk+CiAgPHA+VGhlIHRpbWUgaXMgbm93OiA8c3BhbiBpZD0icmVzdWx0IiAvPjwvcD4KICA8c2NyaXB0Pgp2YXIgd29ya2VyICA9IG5ldyBXb3JrZXIoJ2RhdGE6YXBwbGljYXRpb24vamF2YXNjcmlwdDtiYXNlNjQsYzJWMFNXNTBaWEoyWVd3b1puVnVZM1JwYjI0b0tTQjdDaUFnSUNBZ0lDQWdjRzl6ZEUxbGMzTmhaMlVvYm1WM0lFUmhkR1VvS1NrN0NuMHNJREl3TURBcE93PT0nKTsKd29ya2VyLm9ubWVzc2FnZSA9IGZ1bmN0aW9uIChldmVudCkgewpkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgncmVzdWx0JykuaW5uZXJIVE1MID0gZXZlbnQuZGF0YTsKICAgIH07CiAgPC9zY3JpcHQ+CiA8L2JvZHk+CjwvaHRtbD4=