Javascript 重访时立即显示div

Javascript 重访时立即显示div,javascript,cookies,Javascript,Cookies,在我的页面上,我添加了带有延时内容的DIV。 显然,直到计时器用完,内容才会显示。 请参阅下面的代码 现在的问题是,我想立即显示div 重新访问页面(可能是通过cookie?) 不幸的是,这个编码对我来说太复杂了,我希望有人能帮助我。。。(首选JSFIDLE) 如果你能帮助我,请提前感谢 函数showIt(){ document.getElementById(“optin”).style.visibility=“可见”; } setTimeout(“showIt()”,2000);//110秒

在我的页面上,我添加了带有延时内容的DIV。 显然,直到计时器用完,内容才会显示。 请参阅下面的代码

现在的问题是,我想立即显示div 重新访问页面(可能是通过cookie?)

不幸的是,这个编码对我来说太复杂了,我希望有人能帮助我。。。(首选JSFIDLE)

如果你能帮助我,请提前感谢

函数showIt(){
document.getElementById(“optin”).style.visibility=“可见”;
}
setTimeout(“showIt()”,2000);//110秒(1m50秒)后
嘿
你只能在计时器用完后才能看到这一点

为您的计时器

setTimeout("showIt()", 2000); // after 110 sec (1m50s)
2000是2000ms,2秒。你想要110000,持续110秒

关于设置会话变量:

//checks to make sure the browser supports session storage 
if(typeof(Storage) !== "undefined") {
    //checks to see if the current session variable exists
    if (localStorage.pageVisited) {
        //display the element
        document.getElementById('optin').style.visibility = "visible";
    } else {
        //creates the pageVisited session variable
        localStorage.pageVisited = 1;
    }
}

不太复杂…创建cookie…读取cookie…做有条件的事情…使用sessionStorage或localStorage比使用cookie更好,因为这样代码更少,性能更好。@MarcosPérezGude,对@OP,请参阅: