document.write(" <img id="pic" src='" + filePath + "' width=144px height=115px />"); alert(document.getElementById("pic").src)

解决方案 »

  1.   

    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
    + request.getServerName() + ":" + request.getServerPort()
    + path + "/";
    %>
    <%=path%>就可以显示路径
      

  2.   


    这不行~~
    因为我有个循环打印了若干个~~
    for(var i=0 ; i<4 ; i++){
       document.write(" <img src='" + filePath + "' width=144px height=115px />"); 
    }如果这样的话每次得到的只是第一张的~~
    我要得到我选中的那一章的src~~
      

  3.   

    只能用纯javascript~~
    谢谢您的回答~
      

  4.   


    function showimg(value){
    alert(value);
    }
    document.write(" <img src='" + filePath + "' width=144px height=115px onclick="showimg(this.src)" />"); 
      

  5.   

    你读的时候加个for循环不就能读出来了吗离别id="pic0",id="pic1"等等。
      

  6.   

    如果我有100个~
    那我不就要写100个getElementById?
      

  7.   

    document.onclick=function(e)
    {
      e=e||event;
      var tag=e.target||e.srcElement;
      if(tag.tagName=="IMG")alert(tag.src);
    }
      

  8.   

    for(var i=0 ; i <4 ; i++){ 
      document.write(" <img src='" + filePath + "' width=144px height=115px />"+"onclick='alert("+this.src+")'"); 

      

  9.   


    function show(value){ 
    alert(value); 

    for(var i=0 ; i <4 ; i++){ 
      document.write(" <img src='" + filePath + "' width=144px height=115px />"+"onclick=show(this.src)"); 
    } 试试看:
    (:D
      

  10.   

    PS:
    我的意思是我的页面上有很多张图片!!
    我点击某张图片的时候就获得这张图片的src=""~~
      

  11.   

    document.write(" <img onclick='alert(this.src)' src='" + filePath + "' width=144px height=115px />"); 
      

  12.   


    TMD什么机顶盒的破浏览器? 
    我写成这样,取不出来~~ 
    for(var i=0 ; i <fileNames.length ; i++) { 
        fileName = fileNames[i];  
        document.write("<img src='" + filePath + "' width=144px height=115px onclick='getImageSrc(this)'");           
    } function getImageSrc(img) 

      var test=img.src; 
      alert(test); 

    我写成这样,还是取不出来~~ JScript code
    for(var i=0 ; i <fileNames.length ; i++) { 
        fileName = fileNames[i];  
        document.write("<img src='" + filePath + "' width=144px height=115px onclick='getImageSrc(this.src)'");           
    } function getImageSrc(src) 

     // var test=img.src; 
      alert(src); 
    } 靠~~ 
    在IE都可以~~ 
    真TMD的烂浏览器~~~