0

私は次のことをどのように行うのか疑問に思っています。-私のウェブサイトにVimeoビデオがあります。これは私のウェブサイトの紹介ビデオです。-動画をユーザーに1回だけ表示するか、それが不可能な場合は、ユーザーがページを読み込むたびに5回から10回表示します。

これどうやってするの?私はJSの完全な初心者です。ヒントは大歓迎です!

このスクリプトを見つけましたが、これを行うためにどのように操作/使用しますか?

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

ありがとう!

4

1 に答える 1

2

あなたが見つけたjQuerycookieプラグインはこれを行うことができます。

このコードで始められます。ビデオをどのようにロードしたいかわかりませんが、これで開始できます。

$(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.
  }
});
于 2012-09-18T06:02:06.573 に答える