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
  • 17,728
  • 26
  • 88
  • 122
  • 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
  • 463,167
  • 92
  • 837
  • 979
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
  • 101,278
  • 24
  • 124
  • 158