Storing the Window Object in local storage(将 Window 对象存储在本地存储中)
问题描述
我需要持久化窗口对象的能力.我试图对窗口对象进行字符串化,但在尝试将窗口对象转换为 JSON 时收到错误消息.将循环结构转换为 JSON"错误.无论如何我可以将 window.open 中的 window 对象存储在本地商店中吗?
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.
在本地存储中只能以字符串的形式存储数据,没有办法将window
对象变成字符串以便重新创建相同的window代码>对象.
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 对象存储在本地存储中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 Window 对象存储在本地存储中


基础教程推荐
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01