0

関数が成功メッセージを返す間、以下のコードを使用して新しいウィンドウを開きます。同時に、セルフウィンドウを閉じたいです。今エラーが発生しています:

新しいウィンドウが定義されていません

 var value = getQueryStrings();
 var cust_id = value["cust_id"];
 try {

     PageMethods.add_plan_items(unescape(items), cust_id, device, OnGetMessageSuccess, OnGetMessageFailure);

 } catch (ex) {
     alert(ex);
 }

 function OnGetMessageSuccess(result, userContext, methodName) {
     try {
         var ret_array = result.toString().split(':');
         if (ret_array[0] == "Success Alert ") {

             var left = (screen.width / 2) - 1015 / 2;
             var top = (screen.height / 2) - 550 / 2;

             self.close(); //Close the opened window

             //Enter here and self window is closed

             var newwindow = window.open('test.aspx?id=Y&cust_id=' + cust_id, 'Add Items', 'height=550,width=1000,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left=' + left + ', top=' + top + ',screenX=' + left + ',screenY=' + top + '');
             if (window.focus) {
                 newwindow.focus()
             }
             return false;
         } else {
             self.close(); //Close the opened window
             alert('Error Alert : Error for adding plans in your specified device. Please try again later!');
         }

     } catch (ex) {
         alert(ex);
     }

 }

 function OnGetMessageFailure(error, userContext, methodName) {
     alert(error.get_message());
 }
4

1 に答える 1

0

最初に親ウィンドウを閉じないでください親ウィンドウ
を保存してから、子ウィンドウ(新しいウィンドウ)を開いてから親ウィンドウを閉じます

var parentWindow = self.window;
var newWindow = window.open(...);

parentWindow.close();
于 2013-02-22T07:07:44.160 に答える