在远程Web服务器上检查本地Web服务器是否可访问

问题描述

我在远程网络服务器上有一个网站。用户在此远程服务器上打开一个网站。成功登录后,应将用户重定向到本地Web服务器上的另一个网站。 我要做的是从客户端访问本地Web服务器。如果是这样,则应执行从远程服务器到本地服务器的重定向。否则,将显示一条消息,指出本地服务器与客户端不在同一网络中。

由于登录发生在远程服务器上,因此问题在于服务器端代码当然无法分辨。所以我可能需要像JavaScript这样的基于客户端的语言。

我最后的方法是:using javascript to detect whether the url exists before display in iframe

代码是:

var request;
if(window.XMLHttpRequest)
    request = new XMLHttpRequest();
else
    request = new ActiveXObject("Microsoft.XMLHTTP");
request.open('GET','http://www.mozilla.org',false);
request.send(); // there will be a 'pause' here until the response to come.
// the object request will be actually modified
if (request.status === 404) {
    alert("The page you are trying to reach is not available.");
}

...由于混合内容被Firefox阻止而无法使用: Mixed content blocking in Firefox

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)