我想将DOM节点甚至整个序列化为windowJSON.
例如:
>> serialize(document)
-> {
"URL": "http://stackoverflow.com/posts/2303713",
"body": {
"aLink": "",
"attributes": [
"getNamedItem": "function getNamedItem() { [native code] }",
...
],
...
"ownerDocument": "#" // recursive link here
},
...
}
Run Code Online (Sandbox Code Playgroud)
JSON.stringify(window) // TypeError: Converting circular structure to JSON
Run Code Online (Sandbox Code Playgroud)
问题是JSON默认不支持循环引用.
var obj = {}
obj.me = obj
JSON.stringify(obj) // TypeError: Converting circular structure to JSON
Run Code Online (Sandbox Code Playgroud)
window和DOM节点有很多.window === window.window将如此document.body.ownerDocument === document.
此外,JSON.stringify不序列化函数,所以这不是我想要的.
`dojox.json.ref.toJson()` can easily serialize object with …Run Code Online (Sandbox Code Playgroud) 我在我的数据库中存储点击坐标,然后稍后重新加载它们并在点击发生的网站上显示它们,我如何确保它在同一个地方加载?
存储点击坐标显然是一个简单的步骤,但是一旦我有了它们,如果用户回来并且他们的窗口更小或更大,则坐标是错误的.我是否以错误的方式解决这个问题,我是否还应该存储元素id/dom引用或者那种性质的东西.
此外,此脚本将在具有多个布局的许多不同网站上运行.有没有办法在布局与坐标存储方式无关的情况下执行此操作?