javascript - Storing the Window Object in local storage - Stack Overflow

I need the ability to persist the window object. I tried to stringify the window object but I received

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));

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));
Share Improve this question edited May 22, 2017 at 9:45 mplungjan 179k28 gold badges182 silver badges240 bronze badges asked May 26, 2015 at 16:15 VictorVictor 6661 gold badge5 silver badges17 bronze badges 1
  • Possible duplicate of can I save a window object inside a localStorage – Herohtar Commented Jul 30, 2019 at 4:15
Add a ment  | 

1 Answer 1

Reset to default 4

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745176116a4615201.html

相关推荐

  • javascript - Storing the Window Object in local storage - Stack Overflow

    I need the ability to persist the window object. I tried to stringify the window object but I received

    5小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信