-2

As simple as the title says.

I have a bunch of scripts that work over some javascript code and should execute that code when pressing a button. I use the eval function to do that and it works fine on:

  • GOOGLE CHROME
  • SAFARI
  • OPERA
  • INTERNET EXPLORER (?!?)

Surprisingly this doesn't work on Firefox and if I open the console here is the error I get: [12:17:58.447] ReferenceError: undefinedundefinedundefinedundefinedundefined is not defined

Any idea on how to make it work even on FF?

EDIT. here's the code I use. so much to work on!

function exec_code() {
   var code= document.getElementById("code").innerText;
   eval (code);
}
Jannuzzo
  • 169
  • 1
  • 4
  • 12
  • No, we have no idea how to make the code we can't see work on Firefox. (But if you are using `eval` then you are probably doing something highly sub-optimal anyway). – Quentin Sep 19 '13 at 10:34
  • don't be so nervous.. look at the code and be a little bit more kind the next time. I don't really know how that 2 lines of code can be helpful. Since everything work fine everywhere I really doubt that the problem is the code! – Jannuzzo Sep 19 '13 at 10:41
  • Yes. So much to work on. **What is the value of `code`**? and where does `exec` come from? – Quentin Sep 19 '13 at 10:42
  • 1
    Really hard to tell what you're trying to do with this, but are you sure you really need to use `eval()`? – Spudley Sep 19 '13 at 11:06

1 Answers1

4

Firefox doesn't support the non-standard innerText property.

You can establish this by testing the value of code before you pass it to exec. It will be undefined.

Use something else to get your data.

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335