将cookie设置为与弹出窗口集成

Set cookies in intergrated with pop up

本文关键字:窗口 集成 cookie 设置      更新时间:2023-09-26

我的网站现在在主页中运行javascript弹出窗口,现在我想做的是当用户点击主页时,用户会进入主页,javascript弹出窗口会显示,但在点击关闭后,当用户再次点击主页时这个javascript不会运行,这个脚本只活动一天。

那么,如何将cookie与我的javascript弹出窗口集成?

*这个弹出窗口运行得很完美,但只留下cookie脚本

urlhttp://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>

类似的内容。cookie的过期意味着在该时间之后cookie将被sys删除。谷歌一些文档.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;
    }
}