window.open在新弹出窗口中打开,而不是在新选项卡中打开

时间:2012-09-25 04:39:23

标签: javascript jquery

这是我的ajax请求

 $.ajax({
        type: "POST",
        url: "Performance.aspx/GenerateMatrix",
        data: '{OrgId: ' + $('#hidOrgId').val() + ',SurveyFormId: ' + $('#divMatrixInfo .FeedbackForm').val() + ',GoalId: ' + $('#divMatrixInfo .FeedbackGoal').val() + ',StartDate: ' + "'" + StartDateTime + "'" + ',EndDate: ' + "'" + EndDateTime + "'" + ',EmployeeId: ' + "'" + $('#divMatrixInfo .FeedbackEmployee').val() + "'" + ',QuestionId: ' + "'" + $('#divMatrixInfo .FeedbackQuestion').val() + "'" + '}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
                        CloseModelOverLay('divMatrixInfo');
                        window.open('GenerateMatrix.aspx', '_blank');
                        $('#ddlPDPView').val('Goals');
                        $('#ddlPDPView').change();
        },
        failure: function (response) {
                        alert(response.d);
        }
      });

我想通过此

打开GenerateMatrix.aspx以在新标签中打开
window.open('GenerateMatrix.aspx', '_blank');

但是它会在新的弹出窗口中打开。

1 个答案:

答案 0 :(得分:2)

试试这个:

var newWindow = window.open('http://www.example.com','_blank');

$.ajax({
    type: "POST",
    url: "Performance.aspx/GenerateMatrix",
    data: '{OrgId: ' + $('#hidOrgId').val() + ',SurveyFormId: ' + $('#divMatrixInfo .FeedbackForm').val() + ',GoalId: ' + $('#divMatrixInfo .FeedbackGoal').val() + ',StartDate: ' + "'" + StartDateTime + "'" + ',EndDate: ' + "'" + EndDateTime + "'" + ',EmployeeId: ' + "'" + $('#divMatrixInfo .FeedbackEmployee').val() + "'" + ',QuestionId: ' + "'" + $('#divMatrixInfo .FeedbackQuestion').val() + "'" + '}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (response) {
                    CloseModelOverLay('divMatrixInfo');
                    newWindow.focus();
                    $('#ddlPDPView').val('Goals');
                    $('#ddlPDPView').change();
    },
    failure: function (response) {
                    alert(response.d);
    }
  });