<% 
    String x; 
    x="pppp";     response.write(" <script>alert("&x&"); </script>"); %> 

解决方案 »

  1.   

    <% 
        String x; 
        x="pppp";     response.write(" <script>alert('"&x&"'); </script>"); %> 
      

  2.   

    谢谢各位的回答。三楼与四楼的代码基本相同。都是使用response.write,不同的是在alert中的片断。
    我试了一下,还是不能运行。二楼与五楼说直接使用alert,在上述代码中肯定是不能运行的。
    请各位再指点指点。谢谢
      

  3.   

    <script luanguage=javascript>
    var a="pppp";
        alert (a);
    </script>以上是纯JAVASCRIPT脚本
    以下是asp和javascript脚本的混合使用
    <%
    dim a="pppp";
        response.write("<script luanguage=javascript>{alert("&a&");}</scrit>")
    %>
      

  4.   

    out.print???你是不是刚学jsp?
    javascript:
    <script luanguage=javascript> 
    var a="pppp"; 
        alert (a); 
    </script> 
      

  5.   

    其实问题就是引号的关系。。简单的告诉你判断自己引号是否正确。。在ASP中,判断变量是否因为引号而成为了字符串;就看颜色。。你仔细观察。在DW中,默认变量的颜色应该是黑色的才对,呵呵。。如果是其他颜色了,那肯定就不对!!
      

  6.   

    <% 
        String x; 
        x="pppp";     out.print(" <script>alert(" + x + "); </script>"); %> 
    这样就可以了,你那种方式根本就没有把x的值传进去
      

  7.   

    你这是JSP的吧,像你那样些肯定不行了,应该这样写:<% 
        String x; 
        x="pppp";     out.print("<script>alert("+x+"); </script>"); 
    %> x是变量,不能字符串直接写在一起,要用+连接!
      

  8.   

    out.print(" <script>alert('"&x&"');</script>"); 
      

  9.   

    out.print("<script>alert('"+x+"'); </script>"); 
      

  10.   


    <% 
        String x; 
        x="pppp";     out.print(" <script luanguage='javascript>'");
        out.print(" var a = '" + x +"';");
        out.print(" alert(a);");
        out.print(" </script>");
    %>
    <% 
        String x; 
        x="pppp";     out.print(" <script luanguage='javascript>'");
        out.print(" alert('"+x+"');");
        out.print(" </script>");
    %>
      

  11.   

      out.print("<script luanguage='javascript> alert('"+x+"'); </script>");