Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

Learn More

Do Web Workers Work In FF v43?

  • 6 个回答
  • 1 人有此问题
  • 21 次查看
  • 最后回复者为 cor-el

more options

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

I have the following html page: <pre><nowiki><!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></nowiki></pre> And the worker.js is simply: <pre><nowiki> setInterval(function() { postMessage(new Date()); }, 2000);</nowiki></pre> This works fine in Chrome but I get nothing after "The Time Is Now:" in FireFox? Ideas? Thanks, Ray

由cor-el于修改

所有回复 (6)

more options

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.

more options

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.
more options

Forget it. This sucks!

more options

I've fixed your first question post.


Try to ask advice at the Stack Overflow forum site.

more options

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

more options

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=