<a href="#" onclick="GoDown()">测试</a><script>
var TheUrl="http://我的网址.com/down/";
function GoDown()
{
    var strURL="TMS Component Pack 6.1.4.1 for Delphi & C++Builder 5-XE2 Full Source.rar"
    var strURL=TheUrl+encodeURIComponent(strURL);
    location.href=strURL;
}
</script>
[/code]实现点击"测试"就下载rar,
“http://我的网址.com/down/TMS Component Pack 6.1.4.1 for Delphi & C++Builder 5-XE2 Full Source.rar”是存在的
但点击“测试”总是出错:404 - 找不到文件或目录。
您要查找的资源可能已被删除,已更改名称或者暂时不可用。把加号替换成%2B也还是不行strURL=strURL.replace(/\+/g,"%2B");////替换+
到底是什么问题?

解决方案 »

  1.   

    试一下
      var strURL=TheUrl+strURL;
      location.href=encodeURIComponent(strURL);
    另外好像网页的编码是UTF8的话对于这种中文网址支持会更加好
      

  2.   

      var strURL=TheUrl+strURL;
      location.href=encodeURIComponent(strURL);
    ----不行,Internet Explorer 无法显示该网页编码改成了utf-8也还是不行
      

  3.   

    把URL中的空格替换一下,试试
      

  4.   

    你这种情况,要用encodeURI 的吧
      

  5.   

    index.html
    index.php
    index.jpg
    有没有发现相同点啊,那就是都有“.”点,如果有index.html那么返回,如果没有那么找不到,而你的字符串TMS%20Component%20Pack%206.1.4.1%20for%20Delphi%20%26%20C%2B%2BBuilder%205-XE2%20Full%20Source.rar中的点会被误会的
      

  6.   

         strURL=strURL.replace(/%/g,"%25");////替换%
         strURL=strURL.replace(/\+/g,"%2B");////替换+
         strURL=strURL.replace(/ /g,"%20");////替换空格
          strURL=strURL.replace(/\\/g,"%2F");////替换\
         strURL=strURL.replace(/\?/g,"%3F");////替换?
         strURL=strURL.replace(/#/g,"%23");////替换#
         strURL=strURL.replace(/&/g,"%26");////替换&
         strURL=strURL.replace(/=/g,"%3D");////替换=
         strURL=strURL.replace(/\(/g,"%28");////替换(
         strURL=strURL.replace(/\)/g,"%29");////替换(
    路径有以上特殊字符,我都替换了。
    点.这个没办法替换成其他的,因为文件名称中就有点的,有其他办法解决吗?
      

  7.   

    肯定不是.的问题 你们忘了jquery的文件名了吗jquery-1.7.1.min.js
      

  8.   

    http://我的网址.com/down/TMS Component Pack 6.1.4.1 for Delphi & C++Builder 5-XE2 Full Source.rar替换成最后是:http://我的网址.com/down/TMS%20Component%20Pack%206.1.4.1%20for%20Delphi%20%26%20C%2B%2BBuilder%205-XE2%20Full%20Source.rar还是不行,“http://我的网址.com/down/TMS%20Component%20Pack%206.1.4.1%20for%20Delphi%20%26%20C%2B%2BBuilder%205-XE2%20Full%20Source.rar” 还是返回:
    404 - 找不到文件或目录。
    您要查找的资源可能已被删除,已更改名称或者暂时不可用。文件是肯定存在。
      

  9.   

    “http://我的网址.com/down/TMS Component Pack 6.1.4.1 for Delphi & C++Builder 5-XE2 Full Source.rar”是存在的
    是不是代表直接访问这个url是可以下载的?
      

  10.   

    http://我的网址.com/down/TMS Component Pack 6.1.4.1 for Delphi & C++Builder 5-XE2 Full Source.rar
    直接访问这个url也不能下载-_-!!!
    可是文件真的存在啊,为什么不能下载呢
      

  11.   

    其他rar类的都可以下载,如:a.b.rar
    大小比它大的也能下载还有一个“DevExpress_VCL_v2011_vol_1.6_for_XE2_(Source+Demo+Help).rar”也不能下载,其他的能下载。是url有长度限制吗?两个名称最长的都不能下载
      

  12.   


    encodeURI(encodeURIComponent(url))
      

  13.   


    补充:客户端:url = "http://xxx.xxx.xxx/xxx?path=" + encodeURI(encodeURIComponent(path))服务器端需要反编码还原pathjava代码:
    String path = request.getParameter("path");
    path = java.net.URLDecoder.decode(path , "UTF-8");
      

  14.   

    我的IIS下放了个
    DevExpress_VCL_v2011_vol_1.6_for_XE2_(Source+Demo+Help).rar
    直接可以下载
      

  15.   

    encodeURI(encodeURIComponent(url));
    ----oh,no...不行,Internet Explorer 无法显示该网页
      

  16.   

    <a href="javascript:void(0);" onclick="GoDown();return false;">测试</a><script>
    var TheUrl="http://我的网址.com/down/";
    function GoDown()
    {
      var strURL="TMS Component Pack 6.1.4.1 for Delphi & C++Builder 5-XE2 Full Source.rar"
      var strURL=TheUrl+encodeURIComponent(strURL);
      location.href=strURL;
    }
    </script>