如何在客户端存储用户名列表?

时间:2022-04-15 07:23:34

I have a load of chat boxes which come up on click of a username within a list. The problem is I need to know which are currently chosen to hide/show if more are clicked than there is screen space (think of facebook - you keep clicking friends for private message and when no more fit along the bottom, the next one takes the last boxes spot. Clearly you hide this last one, but want it to come back if you close this current choice)

我有一大堆聊天框,点击列表中的用户名。问题是我需要知道哪些是当前被选中隐藏/显示的,如果点击的次数多于屏幕空间(想想Facebook - 你不断点击朋友的私人消息,当底部不再合适时,下一个拿下最后一个方框现货。很明显你隐藏了最后一个,但是如果你关闭这个当前的选择,希望它回来)

So, I need to cache a list or have a ridiculous number of input boxes in preparation. I have been looking at possibilities and is it possible to implement this with JSON cache? Is there a better option?

因此,我需要缓存一个列表或准备一些荒谬的输入框。我一直在寻找可能性,是否可以使用JSON缓存实现这一点?有更好的选择吗?

If JSON is the best option, please can somebody show me simply:

如果JSON是最好的选择,请有人给我看一下:

-> store array of usernames in jquery to JSON cache -> retrieve JSON cache into jquery array

- >将jquery中的用户名数组存储到JSON缓存 - >将JSON缓存检索到jquery数组中

My JSON knowledge = 0.0001% and this is the only thing I want to use it for for a long time so my jsfiddle attempts failed. If you know any good "beginner / fast skim over" tutorials please link them!

我的JSON知识= 0.0001%,这是我唯一想要长时间使用它的东西所以我的jsfiddle尝试失败了。如果你知道任何好的“初学者/快速浏览”教程,请链接他们!

Many thanks as always

非常感谢一如既往

1 个解决方案

#1


1  

Maybe you should look into the HTML5 feature localStorage

也许您应该查看HTML5功能localStorage

localStorage

localStorage How to use it

localStorage如何使用它

With that you can save the current username list of your users in their browser and access it easily with javascript.

有了它,您可以将用户的当前用户名列表保存在浏览器中,并使用javascript轻松访问。

You can save the data just for the browser session sessionStorage or for longer localStorage, so if the user comes back the next day, his settings will still be set.

您可以仅为浏览器会话sessionStorage或更长的localStorage保存数据,因此如果用户第二天回来,他的设置仍将设置。

#1


1  

Maybe you should look into the HTML5 feature localStorage

也许您应该查看HTML5功能localStorage

localStorage

localStorage How to use it

localStorage如何使用它

With that you can save the current username list of your users in their browser and access it easily with javascript.

有了它,您可以将用户的当前用户名列表保存在浏览器中,并使用javascript轻松访问。

You can save the data just for the browser session sessionStorage or for longer localStorage, so if the user comes back the next day, his settings will still be set.

您可以仅为浏览器会话sessionStorage或更长的localStorage保存数据,因此如果用户第二天回来,他的设置仍将设置。