如何向用户显示一次内容



我想知道如何执行以下操作。- 我的网站上有一个Vimeo视频,这是我网站的介绍视频。- 我希望视频只向用户显示一次,或者如果不可能,则每 5 - 10 次加载页面一次。

我该怎么做?我是JS的新手。欢迎任何提示!

我找到了这个脚本,我将如何操作/使用它来执行此操作?

https://github.com/carhartl/jquery-cookie

谢谢!

你找到的jQuery cookie插件可以做到这一点。

此代码将帮助您入门。我不知道您想如何加载视频,但这将帮助您入门。

$(document).ready(function() {
  var video_cookie = $.cookie('have_seen_video'); // read the cookie
  if (video_cookie == null) {
    // user has not seen the video
    // TODO: show the video
    // save a cookie to indicate this user has seen the video
    $.cookie('have_seen_video', true);
  } else {
    // user has seen video, don't show it again.
  }
});

最新更新