2013-02-22 1 views
0

아래 코드를 사용하여 함수가 성공 메시지를 반환하는 동안 새 창을 엽니 다. 동시에 나는 자기 창을 닫고 싶다. 이제 오류가 점점 오전 :자바 스크립트를 사용하여 aspx에서 창 열기

newwindow is not defined

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()); 
} 
+0

하위 창을 연 다음 부모를 닫습니다. – nsthethunderbolt

답변

0

당신의 부모 창 다음, 당신의 부모 창 첫째
저장을 부모 창을 닫으 자녀 창 (새 창) 열고 닫지 마십시오

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

parentWindow.close(); 
+0

이제 newWindow가 null입니다. – user1951007

+0

원래 코드 w의'newwindow'는 작고 코드 w는 대문자입니다. 변경하십시오 – asifsid88

+0

답장을 보내 주셔서 감사합니다. 이제 newWindow 대신 newwindow를 변경합니다. 하지만 새로운 오류 컨트롤이 페이지의 제어 트리에 있어야한다는 것을 만났습니다. – user1951007

관련 문제