单击后清除jQuery数组

时间:2016-11-17 16:48:00

标签: jquery arrays

我修改了一个jQuery脚本,以便在单击外部链接时显示自定义图层而不是模态图层。我将链接放在一个数组中,直到用户单击“确定”或“取消”并重定向。如果我单击页面上的另一个链接,则会出现问题,然后我单击的每个外部链接都会在单独的选项卡中加载。话虽如此,我无法弄清楚如何在单击“确定”或“取消”后清除阵列。

$('a[href^="http"]').not('a[href^="{{ shop.url }}"]').click(function(e) {
    var external = $(this).attr('href');
    e.preventDefault();

    $('#leaving').toggle('slow');

    $('#linkGo').click(function() {
        $('#leaving').fadeOut(500);
        window.open(window.open.location = external);
    });

    $('#linkCancel').click(function() {
        $('#leaving').fadeOut(500);
    });
});

1 个答案:

答案 0 :(得分:0)

所以...我发现了一个解决方法。一旦我为window.open命令指定了一个窗口名称(不是" _blank")就可以了。如果有不同(或更好)的解决方法,请告诉我。

$('#linkGo').click(function() {
    $('#leaving').fadeOut(500);
    window.open(window.open.location = external , "windowName");
});
相关问题