2014-03-07 13 views
0

我试图从点击打开一个窗口,然后在包含确认页面的url中的响应之后,如果成功,它将关闭窗口。根据结果关闭窗口弹出框

我打开我的窗口,这样的:

 url = 'http:/mywebsite/index'; 
     width = 545; 
     height = 433; 
     var leftPosition, topPosition; 
     //Allow for borders. 
     leftPosition = (window.screen.width/2) - ((width/2) + 10); 
     //Allow for title and status bars. 
     topPosition = (window.screen.height/2) - ((height/2) + 50); 
     //Open the window. 
     window.open(url, "Window2", "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no"); 

的网址http:/mywebsite/index的返回是一个JSON转储的成功是否真或假的字典。我用python btw编码。

我遇到的问题是如何关闭窗口从python的返回。

我试图返回一个字符串作为HTML和JavaScript组成的window.close()。但没有运气。请告诉我,如果我做错了什么或应该是什么方法。

谢谢。

回答

0

您需要存储由window.open返回的对象和调用close()该对象上:

VAR mywindow的;

mywindow = window.open(...);

...

mywindow.close();