I'm trying to stringify a large object with deep hierarchical structure that I have no knowledge of, in order to get rid of it's circular references. It works for the most part except that often I run into same origin policy exception. I have no interest in any child objects with references to other domains or otherwise restricted elements.
JSON.parse(stringify(window));
throws:
Uncaught DOMException: Blocked a frame with origin "http://www.xxxxxx.com" from accessing a cross-origin frame.
How can I avoid the exception by gracefully skipping what causes it and complete the execution of my code given that I have no control over the native JSON.stringify()
code?
JSON.stringify()
is just an example here, I guess more generally what I'm asking is how to evade same origin policy exception if you are not trying to violate it but have to deal with it like in this case?