将Window对象存储在本地存储中 [英] Storing the Window Object in local storage
问题描述
我需要能够持久保存窗口对象。我试图对窗口对象进行字符串化,但在尝试将窗口对象转换为JSON时收到并出错。 将循环结构转换为JSON错误。无论如何我可以从window.open在本地商店中存储窗口对象吗?
I need the ability to persist the window object. I tried to stringify the window object but I received and error when trying to convert the window object to JSON. "Converting circular structure to JSON" error. Is there anyway I can store the window object from a window.open in local store?
var myWindow = window.open("file:///D:/Temp/teststorage.html", "MsgWindow", "width=200, height=100");
localStorage.setItem('Window', JSON.stringify(myWindow));
推荐答案
你不能坚持 window
本地存储中的对象。
You can't persist a window
object in local storage.
您只能在本地存储中以字符串的形式存储数据,并且无法转向将窗口
对象转换为字符串,以便您可以重新创建相同的窗口
对象。
You can only store data in the form of strings in local storage, and there is no way to turn the window
object into a string so that you can recreate the same window
object.
这篇关于将Window对象存储在本地存储中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!