我使用自定义协议从我的网络应用程序打开Windows应用程序它正常工作没有任何问题但是如果Windows应用程序没有被打包在PC中它打开一个新窗口并显示该地址不是没有理解。我想阻止这一点,需要显示一条消息,我当前的代码在下面给出
var url="test:?var="+value+"?var2="+value2+"?var3="+value3;
var win= window.open(url, 'test', 'width=1000,height=700,top=1,left=1,resizable=yes', '1');
if(win==null || win.closed==true)
alert("Please install the application ");
答案 0 :(得分:0)
你能试试吗..
检查未安装Windows应用程序时url
的值是多少。如果为空,我们可以检查..
if(url==null || win.closed==true)
alert("Please install the application ");
答案 1 :(得分:0)
您可以使用ajax。首先发送ajax请求以检查url是否存在。如果不满足打开窗口则给出错误。
function checkUrlstatus (yoururl){
var request = new XMLHttpRequest;
request.open('GET', yoururl, true);
request.send();
request.onreadystatechange = function(){
if(request.readyState==4){
console.log(request.readyState);
// code for opening the url
return true;
}else{
// code for error message on the same page
return false;
}
}
};
答案 2 :(得分:0)
最后我找到了一个解决方案here,它不是防弹的,但它会节省一天