用的是vb.net
程序里这样2句
response.write("<script>alert('……')</script>")
response.redirect("xx.aspx")
为什么直接跳转到xx.aspx而不弹出警告窗口?

解决方案 »

  1.   

    response.write("<script>alert('……');location.href('xx.aspx');</script>")
      

  2.   

    Response.Write("<script>alert('……')<"+"/script>")
    弹不出就分开写
      

  3.   

    Page.RegisterStartupScript("","<script>alert('.....');</script>");
      

  4.   

    用的是vb.net
    程序里这样2句
    response.write("<script>alert('……')</script>")
    response.redirect("xx.aspx")
    为什么直接跳转到xx.aspx而不弹出警告窗口?
    因为
    response.write("<script>alert('……')</script>") 
    ("<script>alert('……')</script>这一段是要发送给IE运行的,但是还没有发送到IE,你的代码已经 
    response.redirect("xx.aspx")
    重导向了,所以直接就导向了
      

  5.   

    这样写能够弹出对话框。试试吧
                message = DeleteUnVisibleChar(“提示信息");
                string js = @"<Script language='JavaScript'>
                    alert('" + message + "');</Script>";
                HttpContext.Current.Response.Write(js);
       
    祝你好远。
      

  6.   

    to:zyug(LovlyPuppy)
    你的方法可行
    但是弹出窗口的时候原来的窗口一片空白了
    请问任何解决?
      

  7.   

    你那样写当然是不行的 <script language=\"javascript\" defer>alert('", strMsg, "');window.location.href='", strUrl, "';</script>"
      

  8.   

    response.write("<script>alert('……')</script>")
    response.redirect("xx.aspx")
    为什么直接跳转到xx.aspx而不弹出警告窗口?
    ==================================================
    因为("<script>alert('……')</script>是给客户端执行的脚本,
    但是在客户端执行之前,必须运行完服务器端代码
    出就是说先运行response.redirect("xx.aspx");
    等转到xx.aspx,但xx.aspx没有
    <script>alert('……')</script>这样的脚本
      

  9.   

    to:zyug(LovlyPuppy)
    你的方法可行
    但是弹出窗口的时候原来的窗口一片空白了
    请问任何解决?
    --------------------------
    Page.ClientScript.RegisterStartupScript(this.GetType(),"key","<script>alert('……');location.href('xx.aspx');</script>");
      

  10.   

    anncesky   解释的非常正确应该用:
    RegisterStartupScript(this.type(),"","<script>alert('……');location.href('xx.aspx');</script>")
      

  11.   

    谢谢楼上的
    但是报错说this没有声明?
      

  12.   

    那就用nullPage.ClientScript.RegisterStartupScript(null,"key","<script>alert('……');location.href('xx.aspx');</script>");你用的是VB.NET还是C#,如果是VB.NET就用Me
      

  13.   

    Page.RegisterStartupScript("anywords","<script>alert('……');location.href('xx.aspx');</script>")
      

  14.   

    up(.net软件外包交流群邀请您的加入 :45638537,我建这个群的初衷是 为有这方面需求的朋友提供一个交流的平台,以方便大家寻找同一城市的合作伙伴)
      

  15.   

    原因就是zyug(LovlyPuppy),anncesky() 所说的
    解决方法就像其他人说的response.write("<script>alert('……')</script>")
    //这句要服务器把这个页面反馈给客户端才会执行(发送到客户端才能够执行)
    response.redirect("xx.aspx")
    //这句在把这个页面反馈之前已经重新导向了(服务器端执行的)