如下代码:
window.location.href="sims://1022";
怎么判断指定的网页是否存在?谢谢!!

解决方案 »

  1.   

     <script language="javascript">        
        var target = null;   
        function createTarget(){   
          if(window.ActiveXObject){   
            target = new   ActiveXObject("Microsoft.XMLHTTP")   ;   
          }else if(window.XMLHttpRequest){   
            target = new XMLHttpRequest();   
          }        
        }   
      function   GetURL(url){      
        createTarget();   
              target.onreadystatechange = function(){   
                     if(target.readyState==4){   
                        if(target.status==200){   
                            alert("页面存在");   
                        }else {   
                            alert("页面不存在");   
                        }   
                      }   
              }   
              target.open("GET",url,true);   
              target.send(null);   
      }      
      
      </script>          <input type="button" onclick="GetURL('http://www.baidu.com')"  
                value="该页面存在">   
            <input type="button"  
                onclick="GetURL('http://www.xxxxxx.com/xxxxx.html')" value="该页面不存在"></input>   
      

  2.   

    这个只适合ie内核的浏览器,ff不支持
      

  3.   

    就是用的ajax 发送和接受请求吧!就是 ajax 兼容各大浏览器的问题了!
      

  4.   

    String realPath = request.getSession().getServletContext().getRealPath(forwardStr);
    boolean exists = new File(realPath).exists();
    if(exists){
    request.getRequestDispatcher(forwardStr).forward(request, response);
    }else{
    request.setAttribute("msg", "404,你懂的,未找到"+forwardStr);
    request.getRequestDispatcher(errorPage).forward(request, response);
    } 后台的,也许你用得到
      

  5.   

    我这样写怎么没响应?
     <input type="button" onclick="GetURL(sims://1022')"   
      value="该页面存在">   
      

  6.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>test</title>
    <script src="jquery-1.4.4.js" type="text/javascript"></script>
    <script type="text/javascript">
        function testPageIsExist(){
            $.ajax({
                url: '1.html',
                type: 'post',
                success: function() {
                    alert("此网页存在!");        
                },
                error: function() {
                    alert("错误,此网页不存在!");        
                }
            });
        }
    </script>
    </head>
    <body>
    <input type="button" id="btnOK" value="测试网页是否存在" onclick="testPageIsExist()" />
    </body>
    </html>测试没有问题, ie, ff都可以的, 你自己附一个jquery的js文件就好了. 
      

  7.   

    谢谢,测试网页没问题,但测试sims://1022没响应啊?
      

  8.   

    用window.location.href="sims://1022";连接有响应,只是不知怎么判断?
      

  9.   

    看看这里就知道了http://fss78.blog.163.com/blog/static/354265720104525149567/