0

Hopscotchのサンプル ツアーでは、パラメーターと呼び出しが設定されていますがhopscotch.startTour(tour);、ページが読み込まれた後、閉じる「x」ボタンも「完了」ボタンも再生を妨げないようです。

それはどのように達成できますか。

4

1 に答える 1

4

onend 関数で localstorage/cookie を利用できます。

function setCookie(key, value) {
    var expires = new Date();
    expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
    document.cookie = key + '=' + value + ';path=/' + ';expires=' + expires.toUTCString();
};

function getCookie(key) {
    var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
    return keyValue ? keyValue[2] : null;
};

var tour = {
    onEnd: function() {
        setCookie("toured", "toured");
    },
    onClose: function() {
        setCookie("toured", "toured");
    }
};

// Initialize tour if it's the user's first time
if (!getCookie("toured")) {
    hopscotch.startTour(tour);
}
于 2015-06-12T19:35:03.737 に答える