1

Possible Duplicates:
Javascript toSource() method not working
Implementing Mozilla’s toSource() method in Internet Explorer.

Is there an alternative method toSource for internet explorer?

Community
  • 1
  • 1
Ben Shelock
  • 20,154
  • 26
  • 92
  • 125
  • 1
    Better Duplicate - [Implementing Mozilla's toSource() method in Internet Explorer](http://stackoverflow.com/questions/171407/implementing-mozillas-tosource-method-in-internet-explorer) – gnarf Jun 18 '10 at 21:03

2 Answers2

4

toSource is non standard and works in the gecko engine only, so will not work in chrome, safari or IE.

See this SO question and answers.

Community
  • 1
  • 1
Oded
  • 489,969
  • 99
  • 883
  • 1,009
0

It is not the same as toSource() but json2.js has JSON.stringify() which will convert a JavaScript object to JSON. This won't convert everything that .toSource() will. It doesn't for instance deal with functions.

gnarf
  • 105,192
  • 25
  • 127
  • 161