我使用如下的代碼顯示出來的photoID值為::/YYOe5J0060.jpg而實際此路徑應為:://YYO/e/5J0060.jpg這問題是出在哪?難道JS中會對字符串作什麼處理嗎?alert("<%=photoID%>");

解决方案 »

  1.   

    试试看
    alert("<%=Replace(photoID,"/","\/")%>");
      

  2.   

    還是不行:整個代碼如下<head>
    <meta http-equiv="Content-Type" content="text/html; charset=big5">
    <link href="css/TextContent.css" style="css/text" rel="stylesheet" />
    <!-- #include file =  "conn.asp" --><%
    Dim rsIma
    photoID = request("photoID")
    if isnull(photoID) OR photoID = "" then
    Set rsIma = server.CreateObject("adodb.recordset")
    sql = "select ima04 from ima_file where ima01 = '"&request("sfd09")&"' "
    rsIma.open sql,conn,1,3
    if not rsIma.eof then
    photoID = rsIma("ima04")
    end if
    set rsIma = nothing
    conn.close()
    end if
    %>
    </head>
    <body>
    <table align="center" >
      <tr>
        <td  ><img onerror="javascript:ChangeUrl(this)" src="<%=photoID%>"> 
        <td valign="top" >&nbsp;&nbsp;
    <a class="linka" href="<%
    if request("sfd09")<>"" then 
    response.write request("PageName")&"?sfd01="&request("sfd01")&"&sfd09="&request("sfd09")&"&ima04="&photoID 
    else 
    response.write request("PageName") 
    end if%>"></a> 
      </tr>
    </table>
    </body>
    </html>
    <Script Language = "JavaScript"> 
    function ChangeUrl(thePhoto){
    thePhoto.src = "images/changeUrl.JPG";
    }
    alert("<%=Replace(photoID,"/","\/")%>"); <!--此句顯示路徑-->
    </script>
      

  3.   

    看上去不应该没有/,没有\是可能的。<%
    photoID = Replace(photoID,"\","\\")
    photoID = Replace(photoID,"/","\/")
    photoID = Replace(photoID,"""","\""")
    %>
    alert("<%=photoID%>");