<a herf="javascript:getpath()"></a>
<script>
function getpath()
{
open("c:\x.doc");
}
</script>没有调过,你试试看。

解决方案 »

  1.   

    <a href="javascript:void()" onclick="this.href=getPath();return true;">aaa</a>
    <script>
    function getPath(){return "C:\\x.doc";}
    </script>
      

  2.   

    用onestab班竹提供的方法,页面上可以用了,但是我在getPath()里面想传入去一个参数,如getPath(pass_id){
    <%
      String id = pass_id;//但这样说出错,不知要怎样才可以?
      GetPathJava gp = new GetPathJava();
      String path = gp.getPathByID(id);
      return path;//这一个path才是最终的绝对路径,刚才没有参数的getPath()只是 一个测试,请问要怎样才可以实现返回这一个path到那个链接?
    %>
    }
      

  3.   

    呵呵,jsp里面怎么能引用javascript的变量?javascript又怎么能写在jsp里面?你先想好你的程序要怎么运行,在服务器端做什么,在客户端做什么,如何交互。
      

  4.   

    To emu(ston): javascript又怎么能写在jsp里面?誰说不能将javascript用在jsp页面,可以啊!
      

  5.   

    ASP  不能直接得到 js 的参数.. 除非这样传. ↓
    或者写入 cookie, 然后用 asp 来读取.getPath(pass_id){
    window.location=window.location+"?pass_id="+pass_id
    <%
      String id = pass_id;
      GetPathJava gp = new GetPathJava();
      String path = gp.getPathByID(id);
      response.write("return "+path);
    %>
    }
      

  6.   

    re: wealth(wealth)
    javascript当然可以用在jsp页面里面,可是不能在java代码中间引用javascript啊。
      

  7.   

    TO: wealth(wealth) 晕死...... 我又没调试环境, 我怎么帮你试??
    我只是告诉你大概该怎么做, 代码都没写全.你自己就不晓得动下脑子改改?
    非得别人喂到你嘴里啊?!.
      

  8.   

    搞了一个下午终于做出来了,方法:在servlet里面用response.sendRedirect(redirectPath);就可以直接弹出下载框了!!!