1

知道如何让这个(工作的)js 位在几秒钟内被格式化为https://github.com/carhartl/插件设置的过期参数吗?

这是我所拥有的,运行良好(也与 ominflowWindow 一起使用):

function OverlayClose() {
        jQuery(".ow-overlay, .modal").hide("slow");
    }
jQuery(document).ready(function () {
    if (jQuery.cookie('product_2min_modal') == null) {
        jQuery.cookie('product_2min_modal', 'yes', {
            expires: 1,
            path: '/'
        });
        setTimeout(function () {
            jQuery('div.modal').omniWindow() // create modal
            .trigger('show');
        }, 5000 // and show it
        );
    }
});

我可以直接在函数中编码吗,像这样?

function OverlayClose() {
            jQuery(".ow-overlay, .modal").hide("slow");
        }
    jQuery(document).ready(function () {
        if (jQuery.cookie('product_2min_modal') == null) {
            jQuery.cookie('product_2min_modal', 'yes', {
                expires:  
var date = new Date();
 var minutes = 2;
 date.setTime(date.getTime() + (minutes * 60 * 1000));
 $.cookie("product_2min_modal", { expires: date });
,
                path: '/'
            });
            setTimeout(function () {
                jQuery('div.modal').omniWindow() // create modal
                .trigger('show');
            }, 5000 // and show it
            );
        }
    });
4

1 回答 1

2

您有语法错误

function OverlayClose() {
    jQuery(".ow-overlay, .modal").hide("slow");
}
jQuery(document).ready(function () {
    if (jQuery.cookie('product_2min_modal') == null) {
        var date = new Date();
        var minutes = 2;
        date.setTime(date.getTime() + (minutes * 60 * 1000));
        jQuery.cookie('product_2min_modal', 'yes', {
            expires: date,
            path: '/'
        });
    }
});
于 2013-09-03T10:42:19.197 回答