0
我在想如何做到以下幾點。 - 我的網站上有一個Vimeo視頻,它是我網站的介紹視頻。 - 我希望視頻僅向用戶顯示一次,或者如果不可行,則每5到10次加載一次頁面。如何向用戶顯示一次內容
我該怎麼做?我是JS的完全新手。任何提示都歡迎!
我發現這個腳本,我將如何操作/使用它來做到這一點?
https://github.com/carhartl/jquery-cookie
謝謝!
我在想如何做到以下幾點。 - 我的網站上有一個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.
}
});
謝謝! :) – Airman