Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要一些代码的帮助,伙计们。我想使用媒体存储来存储一组用户的用户界面值。我正在考虑通过样式表提供多种样式,但无法弄清楚如何让用户偏好保留默认样式表,我是否需要在 html5 存储中使用某种 javascript 触发器?
您可以使用 localStorage 保存键/值对:
localStorage.setItem('alpha','beta');
您可以稍后使用以下方法从 localStorage 中获取值:
localStorage.alpha;
或者
localStorage.getItem('alpha');
然后,您可以使用一些 javascript 根据从 localStorage 检索到的值更改样式表。