Vanwege onderhoudswerkzaamheden die uw ervaring zouden moeten verbeteren, heeft deze website beperkte functionaliteit. Als een artikel uw probleem niet verhelpt en u een vraag wilt stellen, kan onze ondersteuningsgemeenschap u helpen in @FirefoxSupport op Twitter en /r/firefox op Reddit.

Zoeken in Support

Vermijd ondersteuningsscams. We zullen u nooit vragen een telefoonnummer te bellen, er een sms naar te sturen of persoonlijke gegevens te delen. Meld verdachte activiteit met de optie ‘Misbruik melden’.

Meer info

Deze conversatie is gearchiveerd. Stel een nieuwe vraag als u hulp nodig hebt.

Do Web Workers Work In FF v43?

  • 6 antwoorden
  • 1 heeft dit probleem
  • 21 weergaven
  • Laatste antwoord van 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

Bewerkt door cor-el op

Alle antwoorden (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=