Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery UI:在新窗口中打开链接的按钮_Javascript_Jquery Ui_Jquery Ui Dialog - Fatal编程技术网

Javascript jQuery UI:在新窗口中打开链接的按钮

Javascript jQuery UI:在新窗口中打开链接的按钮,javascript,jquery-ui,jquery-ui-dialog,Javascript,Jquery Ui,Jquery Ui Dialog,我有以下代码 var targetUrl = $(this).attr("href"); $("#leaving-dialog").dialog({ buttons: { "No, I want to stay here": function () { $(this).dialog("close"); }, "Yes, that's okay": function () { window.lo

我有以下代码

var targetUrl = $(this).attr("href");
$("#leaving-dialog").dialog({
    buttons: {
        "No, I want to stay here": function () {
            $(this).dialog("close");
        },
        "Yes, that's okay": function () {
            window.location.href = targetUrl;
        }
    }
});
这基本上使其中一个按钮将用户发送到某个地方。我想让它做的是,在一个新窗口或选项卡中打开链接,然后关闭模式(因为他们仍然会打开原始页面)

知道如何解决这个问题吗?

使用
window.open(targetUrl)
而不是
window.location.href
,然后将该行添加到
关闭
对话框中

下面是一个示例(使用jQuery UI文档中的一些示例
对话框
代码,我还没有包括CSS文件,所以它看起来不像一个对话框!)