Cerca nel supporto

Attenzione alle mail truffa. Mozilla non chiederà mai di chiamare o mandare messaggi a un numero di telefono o di inviare dati personali. Segnalare qualsiasi attività sospetta utilizzando l'opzione “Segnala abuso”.

Ulteriori informazioni

Questa discussione è archiviata. Inserire una nuova richiesta se occorre aiuto.

Do Web Workers Work In FF v43?

  • 6 risposte
  • 1 ha questo problema
  • 21 visualizzazioni
  • Ultima risposta di 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

Modificato da cor-el il

Tutte le risposte (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=