如何关闭在Javascript中找不到请求页面的页面 [英] how to close request page not found page in Javascript

查看:55
本文介绍了如何关闭在Javascript中找不到请求页面的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经返回了在服务器上打开文件的功能.

Hi All,

I have return the function to open a file on server.

var doc=businessObject.selectSingleNode(".//Repair_Notification_Number").text;
window.open("/RepairDocument/"+doc+".pdf");  
HTTPstatus();



HTTPstatus()函数是-



The HTTPstatus() function is -

function HTTPstatus() 
{
 
var request = new ActiveXObject("Microsoft.XMLHTTP");
request.open('GET', '/RepairDocument/"+doc+".pdf', false);   
request.send(null);  
if (request.status == 200)  
alert(request.responseText);  
else
window.opener.close("/RepairDocument/"+".//Repair_Notification_Number"+".pdf"); 
alert("PDF is not generated for this notification please contact HO");
 
} 


现在,如果要关闭其他页面中没有的页面,请关闭它.
我尝试使用window.close()函数,但是它没有关闭该页面.我应该如何关闭此窗口.

该怎么做?
请指导我.


Now I want to close that page not found window if it comes in else part.
I have tried to use window.close()function but it is not closing that page.How should I close this window.

How to do this?
Please guide me.

推荐答案

您将必须在某些变量中保留对已打开"窗口的引用,然后使用该变量关闭相应的Window.

请尝试以下代码.
You will have to keep reference of your Opened window in some variable, and then use that variable to close corresponding Window.

Try as below code.
var doc = businessObject.selectSingleNode(".//Repair_Notification_Number").text;
var myWindow = window.open("/RepairDocument/"+doc+".pdf");  

HTTPstatus(myWindow);


function HTTPstatus(myWindow) 
{ 
var request = new ActiveXObject("Microsoft.XMLHTTP");
request.open('GET', '/RepairDocument/"+doc+".pdf', false);   
request.send(null);  
if (request.status == 200)  
alert(request.responseText);  
else
myWindow.close();
alert("PDF is not generated for this notification please contact HO");
 
} 


这篇关于如何关闭在Javascript中找不到请求页面的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆