【问题标题】:how to check if IE 5.5 is online如何检查 IE 5.5 是否在线
【发布时间】:2013-11-08 08:33:07
【问题描述】:

我正在尝试使用 javascript 检查浏览器是否有互联网连接,但我在 IE 5.5 上遇到了一些问题

<script>
function checkConnection(){
           if(navigator.onLine === false){
               //document.execCommand("Stop");
               alert("No internet connection.");
               document.execCommand("Stop");
}
</script>

和:

<input type="submit" value="GO" name="whereTo" onclick="checkConnection();"  />

似乎 IE 5.5 没有 navigator.onLine 属性,如何检查 IE 5.5 的连接?

【问题讨论】:

  • 我猜你不应该想处理这些过时的东西......
  • IE 5.5?那是13年前发布的!你真的需要支持吗?
  • Internet Explorer 5.5 时代还没有发明互联网
  • IE5.5 就像一扇敞开的大门,让病毒和蠕虫进入...
  • 告诉他们买一部新手机?

标签: javascript internet-explorer navigator internet-explorer-5


【解决方案1】:

为什么不尝试发送 AJAX 请求? 它不会检查您是否严格在线,但会告诉您是否可以访问某些内容...尝试几个 URL 可能就足够了...

function ajaxRequest(url) {
  var xmlhttp;
  if (window.XMLHttpRequest) {
    // code for IE 7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }  else {
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState !== 4 && xmlhttp.status !== 200) {
      alert("No internet connection.");
      document.execCommand("Stop");
    }
  }

  xmlhttp.open("GET",url, true);
  xmlhttp.send();
  return false;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-01
    • 1970-01-01
    • 2016-01-16
    • 2015-01-25
    • 2011-09-28
    • 2018-03-21
    • 1970-01-01
    相关资源
    最近更新 更多