Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.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
Jquery :today.getDate()+1, m:今天。getMonth(), y:今天,getFullYear() }; var expiredate=新日期(t.y,t.m,t.d,00,01,00,00); expires=“;expires=“+expiredate.togmString(); }否则{ 变量日期=新日期(); date.setTime(date.getTime()+(天*24*60*60*1000)); expires=“;expires=“+date.togmString(); } } //document.cookie=name+“=”+value+expires+“path=/” document.cookie=name+“=”+value+expires+”;path=“+window.location.pathname; } window.readCookie=函数(名称){ 变量nameEQ=name+“=”; var ca=document.cookie.split(“;”); 对于(变量i=0;i_Jquery_Html_Css - Fatal编程技术网

Jquery :today.getDate()+1, m:今天。getMonth(), y:今天,getFullYear() }; var expiredate=新日期(t.y,t.m,t.d,00,01,00,00); expires=“;expires=“+expiredate.togmString(); }否则{ 变量日期=新日期(); date.setTime(date.getTime()+(天*24*60*60*1000)); expires=“;expires=“+date.togmString(); } } //document.cookie=name+“=”+value+expires+“path=/” document.cookie=name+“=”+value+expires+”;path=“+window.location.pathname; } window.readCookie=函数(名称){ 变量nameEQ=name+“=”; var ca=document.cookie.split(“;”); 对于(变量i=0;i

Jquery :today.getDate()+1, m:今天。getMonth(), y:今天,getFullYear() }; var expiredate=新日期(t.y,t.m,t.d,00,01,00,00); expires=“;expires=“+expiredate.togmString(); }否则{ 变量日期=新日期(); date.setTime(date.getTime()+(天*24*60*60*1000)); expires=“;expires=“+date.togmString(); } } //document.cookie=name+“=”+value+expires+“path=/” document.cookie=name+“=”+value+expires+”;path=“+window.location.pathname; } window.readCookie=函数(名称){ 变量nameEQ=name+“=”; var ca=document.cookie.split(“;”); 对于(变量i=0;i,jquery,html,css,Jquery,Html,Css,cookie将过期,因此…使用上述功能,您可以保存、读取和删除任何cookie。此cookie将在F5之间持续存在,并在特定日期过期 其他可能的技术有“LocalStorage”“WebStorage”LocalStorage将是一个很好的解决方案。如果用户访问您的站点,您只需在存储器中保存一个布尔值。当用户访问您的站点时,您将检查该值是否存在。如果是,则不显示弹出窗口,如果否,则显示弹出窗口 //read from local storage var popupdisplayed = loca

cookie将过期,因此…使用上述功能,您可以保存、读取和删除任何cookie。此cookie将在F5之间持续存在,并在特定日期过期


其他可能的技术有“LocalStorage”“WebStorage”

LocalStorage将是一个很好的解决方案。如果用户访问您的站点,您只需在存储器中保存一个布尔值。当用户访问您的站点时,您将检查该值是否存在。如果是,则不显示弹出窗口,如果否,则显示弹出窗口

//read from local storage
var popupdisplayed = localStorage.getItem('popupdisplayed');

jQuery(function() {
    jQuery('[data-popup-close]').on('click', function(e) {
    var targeted_popup_class = jQuery(this).attr('data-popup-close');
    jQuery('[data-popup="' + targeted_popup_class + '"]').fadeOut(350);
    e.preventDefault();
  });
});

jQuery(document).ready(function() {
    //if popupdisplayed is null, the user has not visited the site before
    if(popupdisplayed === null) {
        jQuery('.popup').show(0);
        var halfbrowserHeight = jQuery(window).height() / 2;
        jQuery(window).scroll(function() {
            var distance = jQuery(window).scrollTop();
            if (distance >= halfbrowserHeight && !popupdisplayed) {
            jQuery('.popup').show(0);
            //save in local storage
            localStorage.setItem('popupdisplayed', true); 
        }
    }
  });
});

当用户访问您的站点时,您还可以使用存储标志。它将在浏览器会话中可用,但您必须考虑到,如果用户更改浏览器或清除存储,则标志将丢失。要跨浏览器或计算机使用,您必须将标志存储在后端,并选中它以显示或不显示弹出窗口。

使用cookie。如果页面加载时cookie不存在,则显示弹出窗口并设置cookie。是的,这是个好主意。谢谢Cookie通常由服务器读取。但是您的服务器不需要读取它,您只需要在客户端读取它。因此,本地存储将是一个更好的解决方案。@RoryMcCrossan,如果他清除cookie或history,我的cookie将被删除,那么用户将再次位于第一个用户之下?这是正确的。你对此无能为力我怎么办?有什么方向吗?加上一些例子,还有一些其他的方法博文代码不起作用,先生!当我尝试粘贴上面的代码时,它不会显示任何内容。
//read from local storage
var popupdisplayed = localStorage.getItem('popupdisplayed');

jQuery(function() {
    jQuery('[data-popup-close]').on('click', function(e) {
    var targeted_popup_class = jQuery(this).attr('data-popup-close');
    jQuery('[data-popup="' + targeted_popup_class + '"]').fadeOut(350);
    e.preventDefault();
  });
});

jQuery(document).ready(function() {
    //if popupdisplayed is null, the user has not visited the site before
    if(popupdisplayed === null) {
        jQuery('.popup').show(0);
        var halfbrowserHeight = jQuery(window).height() / 2;
        jQuery(window).scroll(function() {
            var distance = jQuery(window).scrollTop();
            if (distance >= halfbrowserHeight && !popupdisplayed) {
            jQuery('.popup').show(0);
            //save in local storage
            localStorage.setItem('popupdisplayed', true); 
        }
    }
  });
});