【问题标题】:How to trigger a specific action if the user has been on the website before?如果用户之前访问过网站,如何触发特定操作?
【发布时间】:2021-01-06 00:59:21
【问题描述】:

所以基本上,我在网站上有一个代码,一旦用户到达网站,就会播放嵌入式 soundcloud 播放列表。但是,我想做一些事情,每次用户访问网站时都会播放不同的播放列表。所以基本上:

If user visits the website for the first time
 then play playlist 1
If user visits the website for the second time
 then play playlist 2
If user visits the website for the third time
 then play playlist 3
Elseif user visiting the website for the fourth time
 then play playlist 1 again

然后重复。

(我可以播放 3-4 个不同的播放列表)

我对 JS 编程有点陌生,所以我想知道是否有一种方法可以使用 cookie 或本地存储来确定用户第 n 次访问网站并相应地播放播放列表。

如果我可以提供更多信息或澄清,请告诉我。再说一次,我对编程比较陌生,所以对于任何含糊之处,我深表歉意。

【问题讨论】:

标签: javascript html cookies local-storage


【解决方案1】:

是的,cookie 是您必须使用的。用户有可能清除他们的 cookie,但这就是它的工作原理。您将访问次数存储在 cookie 中,并根据该次数显示/执行您需要的任何操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    相关资源
    最近更新 更多