Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用跳房子自动播放巡演,并且在关闭/完成后再也不播放?_Javascript_Jquery_Hopscotch - Fatal编程技术网

Javascript 使用跳房子自动播放巡演,并且在关闭/完成后再也不播放?

Javascript 使用跳房子自动播放巡演,并且在关闭/完成后再也不播放?,javascript,jquery,hopscotch,Javascript,Jquery,Hopscotch,设置参数并调用hopsocch.startTour(tour)但是,无论是关闭“x”还是“完成”按钮似乎都无法阻止页面加载后再次播放 如何实现这一点?您可以在oned函数上使用localstorage/cookie function setCookie(key, value) { var expires = new Date(); expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000)); documen

设置参数并调用
hopsocch.startTour(tour)但是,无论是关闭“x”还是“完成”按钮似乎都无法阻止页面加载后再次播放


如何实现这一点?

您可以在oned函数上使用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);
}

您可以在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);
}