在 html 页面之间传递 javascript 对象 [英] Pass javascript objects between html pages

查看:62
本文介绍了在 html 页面之间传递 javascript 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 javascript 中创建了一个类,其中包含一个包含变量和函数的对象.我在一个 .html 页面中实例化对象,但是当我更改到另一个 .html 页面时,该对象似乎是空的".如何将对象在一个页面之间传递到另一个页面?

I have made a class in javascript with an object that contains both variables and functions. I instantiate the object within one .html page, but when I change to another .html page, the object seems to be 'empty'. How can I pass the object between one page to another?

推荐答案

你可以看看 网络存储.这将不允许您存储完整的 JavaScript 对象,但是您可以存储任意数量的字符串名称-值对.永久(在浏览器重新启动之间)或作为会话的一部分.

You can have a look at Web Storage. This won't allow you to store a full JavaScript object, however you will be able to store as many string name-value pairs as you want. Either permanently (between browser restarts) or as part of a session.

这篇关于在 html 页面之间传递 javascript 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆