0

我有一个div使用 jquery+css 消失的。它工作得很好,但我遇到了一个问题。div下次用户在同一个 wordpress 网站上打开页面时,我如何才能让它不重新加载。因为div存在于 中header.php,所以每次调用新页面时都会如此div,即使用户之前关闭了它。

有没有办法使用现有的基础设施确保每次访问只加载一次横幅?我觉得必须有某种方法可以做到这一点,特别是因为 wordpress 是在 php 上运行的,但我有点超出我的深度。

这是我目前正在编辑的网站,这里是与横幅相关的代码。

HTML:

<div id="greenbanner">
<img src="<?php bloginfo('template_directory'); ?>/Devices.png" id="devices">
<img src="<?php bloginfo('template_directory'); ?>/bigx.png" id="bigx">
<div id="bannertext">Spundge lets you discover, <br />curate, and create better content. <br /><br />
<div id="jointhedarkside"><a style="color:#ffffff;" href="https://www.spundge.com/account/signup/">Get Started - It's Free</a></div>
</div>
</div>  

查询:

$(document).ready(function(){
$("#headershadow").hide();
$("#bigx").click(function(){
  $("#greenbanner").hide(1000);
  $("#headershadow").show();
});
});

CSS:

#greenbanner {
    width: 100%;
    height: 200px;
    background-color: #ffffff;
    background: rgba(248,80,50,1);
    background: -moz-linear-gradient(top, rgba(248,80,50,1) 0%, rgba(82,133,48,1) 0%, rgba(241,111,92,1) 0%, rgba(82,133,48,1) 0%, rgba(87,219,0,1) 0%, rgba(76,140,30,1) 83%, rgba(76,140,30,1) 100%);
    background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(248,80,50,1)), color-stop(0%, rgba(82,133,48,1)), color-stop(0%, rgba(241,111,92,1)), color-stop(0%, rgba(82,133,48,1)), color-stop(0%, rgba(87,219,0,1)), color-stop(83%, rgba(76,140,30,1)), color-stop(100%, rgba(76,140,30,1)));
    background: -webkit-linear-gradient(top, rgba(248,80,50,1) 0%, rgba(82,133,48,1) 0%, rgba(241,111,92,1) 0%, rgba(82,133,48,1) 0%, rgba(87,219,0,1) 0%, rgba(76,140,30,1) 83%, rgba(76,140,30,1) 100%);
    background: -o-linear-gradient(top, rgba(248,80,50,1) 0%, rgba(82,133,48,1) 0%, rgba(241,111,92,1) 0%, rgba(82,133,48,1) 0%, rgba(87,219,0,1) 0%, rgba(76,140,30,1) 83%, rgba(76,140,30,1) 100%);
    background: -ms-linear-gradient(top, rgba(248,80,50,1) 0%, rgba(82,133,48,1) 0%, rgba(241,111,92,1) 0%, rgba(82,133,48,1) 0%, rgba(87,219,0,1) 0%, rgba(76,140,30,1) 83%, rgba(76,140,30,1) 100%);
    background: linear-gradient(to bottom, rgba(248,80,50,1) 0%, rgba(82,133,48,1) 0%, rgba(241,111,92,1) 0%, rgba(82,133,48,1) 0%, rgba(87,219,0,1) 0%, rgba(76,140,30,1) 83%, rgba(76,140,30,1) 100%);
    margin-top: 5px;
}

#devices {
    height: 200px;
    margin-left: 5%;
}

#bigx {
    float: right;
    margin-bottom: 260px;
    margin-top: 10px;
    margin-right: 20px;
}
#bigx:hover {
    opacity: 0.4;
    filter:alpha(opacity=40);
    cursor: pointer;
}

#jointhedarkside {
    font-family: Geogrotesque, Lucida Sans Unicode, sans-serif;
    font-weight: 500;
    color: #ffffff;
    background-color: #57db00;
    border-radius: 5px;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-right: 10px;
    padding-left: 10px;
    font-size: 18px;
    letter-spacing: normal;
    text-transform: uppercase;
    display: block; 
    float: left;
    line-height: 17px;
}
#jointhedarkside:hover {
    cursor: pointer;
    background-color: #46ab00;
}

    #bannertext {
        font-family: Geogrotesque, Lucida Sans Unicode, sans-serif;
        font-weight: 100;
        color: #ffffff;
        padding-top: 50px;
        margin-left: 80px;
        padding-right: 25px;
        padding-left: 5px;
        font-size: 30px;
        letter-spacing: normal;
        text-transform: uppercase;
        display: block; 
        float: left;
    }
4

2 回答 2

3

您设置了一个 cookie,如果找到它,可能甚至不会在您的 PHP 中呈现该框。

于 2013-05-22T16:25:34.930 回答
0

为此,您可以在 javascript 中使用 cookie 功能。存储一个表示 div status 的值。每次页面加载时检查。

于 2013-06-24T19:30:56.033 回答