Установить куки в JavaScript - интегрированы с всплывающим - PullRequest
0 голосов
/ 15 марта 2012

мой веб-сайт теперь запускает всплывающее окно javascript на домашней странице, теперь я хочу это сделать, когда пользователь нажимает на домашнюю страницу, пользователь переходит на домашнюю страницу, и отображается всплывающее окно javascript, но после нажатия кнопки "Закрыть" и при повторном нажатии пользователем на домашнюю страницу этот JavaScript не будетзапустить, этот скрипт активен только в течение одного дня.

Итак, как интегрировать куки с моим всплывающим javascript?

* это всплывающее окно работает отлично, но только оставил скрипт куки

url http://tsubamecorp.com/home/index.php?route=extras/blog/getblogcategory&blogpath=41

это мое всплывающее окно JavaScript:

<script>

    var $xx = jQuery.noConflict();

    $xx(document).ready(function() {

    //select all the a tag with name equal to modal
    $xx('a[name=modal]').click(function(e) {
        //Cancel the link behavior
        e.preventDefault();

        //Get the A tag
        var id = $xx(this).attr('href');

        //Get the screen height and width
        var maskHeight = $xx(document).height();
        var maskWidth = $xx(window).width();

        //Set heigth and width to mask to fill up the whole screen
        $xx('#mask').css({'width':maskWidth,'height':maskHeight});

        //transition effect     
        $xx('#mask').fadeIn(1000);  
        $xx('#mask').fadeTo("slow",0.90);   

        //Get the window height and width
        var winH = $xx(window).height();
        var winW = $xx(window).width();

        //Set the popup window to center
        $xx(id).css('top',  winH/2-$xx(id).height()/1);
        $xx(id).css('left', winW/2-$xx(id).width()/2);

        //transition effect
        $xx(id).fadeIn(1000); 

    });

    //if close button is clicked
    $xx('.window .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();

        $xx('#mask').hide();
        $xx('.window').hide();
    });             

});
</script>
<script type="text/javascript">
window.onload = function() { $xx('a[href="#dialog1"]:eq(0)').click();
 }
</script>

1 Ответ

0 голосов
/ 15 марта 2012

как то так. истекает срок действия cookie-файла после того, как sys удалит его. Google немного документа.cookie

 Cookie = {
    get:function  ( key ) {
        var ret = this.toObj()[key];
        if( ret === undefined ){
            return ret;
        }
        return unescape ( this.toObj()[key] );
    },
    set:function  ( key, value, expires ) {
        if ( expires ){
            var exdata = new Date();
            exdata = exdata.setDate ( exdata.setDate() + expires ).toGMTString();
        }
        document.cookie = key+"="+escape(value) + ( exdata ? "; expires= " + exdata : "");
    },
    remove:function  ( key ) {
        document.cookie = key+"=remove;expires="+(new Date).toGMTString();
    },
    toJSON:function  (  ) {
        return JSON.stringify( this.toObj );
    },
    toObj:function  (  ) {
        var ret={}, cookiearr = document.cookie.split(";");
        var i, start, key, value;
        for ( i = 0; l = cookiearr[ i++ ];) {
            start = l.indexOf ("=");
            ret [ l.slice(0, start) ] = l.slice (start+1);
        }
        return ret;
    }
}
...