当您无法控制相同的原始政策错误时如何规避它

时间:2015-10-18 18:31:07

标签: javascript exception error-handling try-catch same-origin-policy

我正在尝试使用我不知道的深层次结构对大型对象进行字符串化,以便摆脱它的循环引用。除了通常我遇到相同的原始策略异常之外,它大部分都有效。我对引用其他域或其他受限元素的任何子对象不感兴趣。

JSON.parse(stringify(window));

抛出:

Uncaught DOMException: Blocked a frame with origin "http://www.xxxxxx.com" from accessing a cross-origin frame.

如果我无法控制原生JSON.stringify()代码,如何通过优雅地跳过导致异常的原因并完成代码的执行来避免异常?

JSON.stringify()在这里只是一个例子,我想更普遍的是我要问的是如果你不是试图违反它而如何不得不像在这种情况?

1 个答案:

答案 0 :(得分:0)

试试看!首先,您需要删除页面上的所有iframe,以防止出现跨原点错误。然后,您可以运行replacer函数作为UnsatisfiableError: The following specifications were found to be incompatible with the existing python installation in your environment: Specifications: - jupyterq -> python[version='>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0'] Your python: python=3.8 If python is on the left-most side of the chain, that's the version you've asked for. When python appears to the right, that indicates that the thing on the left is somehow not available for the python version you are constrained to. Note that conda will not change your python version to a different minor version unless you explicitly specify that. The following specifications were found to be incompatible with your CUDA driver: - feature:/win-64::__cuda==9.1=0 - feature:|@/win-64::__cuda==9.1=0 Your installed CUDA driver is: 9.1 的第二个参数,以检查并丢弃循环引用。

JSON.stringify()