首页 > 解决方案 > 在 cookie 中使用 javascript 临时保留更改

问题描述

我正在尝试进行概念验证并编写了一个函数,将我当前网页中的值和样式替换为JavaScript

例子;

const headerColor = document.getElementById("topheader");
headerColor.style.backgroundColor = 'white';
headerColor.style.background = 'none';

我想知道我是否可以将所有这些保存在一个 cookie 中,以便在整个结帐过程中创建具有这些样式的演示。

例如,我暂时将页面标题替换为JavaScript并希望将其保留在 cookie 中以供会话的剩余部分使用。

这可能吗?

标签: javascripthtmlcssgoogle-chromegoogle-chrome-devtools

解决方案


推荐阅读