views:

275

answers:

1

Hi. I'd like to store some internal Javascript object like Range but I haven't found a way to save it. What's the best way to save it ? I thought to serialize it but I haven't found anything on the net.

Is there a library that helps doing that? jquery?

A: 

Look into the Javascript stringify() function that is floating around. See here:

http://www.thomasfrank.se/json_stringify_revisited.html

Direct link to the code.

RedFilter
apparently it doesn't work with a Range object(document.createRange() )
This is the error I get when I try with a Range object. Not sure if someone here can help..Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: http://localhost/~mgalli/jsonStringify.js :: anonymous :: line 87" data: no]
var ra = new Object();ra = document.createElement("b");var s = JSONstring.make(ra);alert('ra ' + s);