象有些网站里经常有“三秒内即将跳转到”我想在点“提交”按钮后在后台里实现三秒自动跳转,该怎么写啊?我写的老是不会跳转,说“缺少:”
-----------点“提交”后的代码------------
int intQuestionId = 0;
string strUrl = "question.aspx?id=" + intQuestionId;
strJavaScript = strJavaScript + "<script>";
strJavaScript = strJavaScript + "window.setTimeout('" + strUrl + "',3000);";
strJavaScript = strJavaScript + "</script>"; //三秒后跳转到提交的帖子页面if (question.addquestion() > 0)
{
   lblMsg.Text = "<font color='#4384f0'>问题已经提交!三秒后自动跳转到该问题所在页面</font>";
   Response.Write(strJavaScript);
}

解决方案 »

  1.   

    <script>
    setTimeout('window.location="home.aspx"',3000)
    </script>
      

  2.   

    string strUrl = "window.location = question.aspx?id=" + intQuestionId;
    strJavaScript = strJavaScript + "<script>";
    strJavaScript = strJavaScript + "window.setTimeout('" + strUrl + "',3000);";
    strJavaScript = strJavaScript + "</script>";
    改成这样
      

  3.   

    jimu8130(火箭能否升空?) 按你的改了后,页面没有跳转啊
      

  4.   

    jimu8130(火箭能否升空?)  按你的改了后,页面没有跳转啊,还是会出现“缺少:"的错误
      

  5.   

    <script>
    setTimeout('window.location="home.aspx"',3000)
    </script>
    正解
      

  6.   

    string strUrl = "window.location = question.aspx?id=" + intQuestionId;
    strJavaScript = strJavaScript + "<script>";
    strJavaScript = strJavaScript + "window.setTimeout('" + strUrl + "',3000);";
    strJavaScript = strJavaScript + "</script>";
    我跟踪了一下,strJavaScript="<script>window.setTimeout('window.location=question.aspx?id=110',3000);</script>"但是Page.RegisterStartupScript("",strJavaScript);执行完后就报错说“缺少:”,都不知道哪里缺":"??
      

  7.   

    总算搞定了!按照<script>setTimeout('window.location="home.aspx"',3000);</script>这样再在后台代码里拼这样一个语句出来,而我原来没有拼"home.aspx"的两个引号。所以应该是这样才可以。就加了一个转义字符来做一对双引号就行了。谢谢大家,谢谢! ^_^
    strUrl = strUrl + "window.location=";
    strUrl = strUrl + "\"" + "question.aspx?questionId=" + intQuestionId.ToString() + "\"";
    strJavaScript = strJavaScript + "<script>";
    strJavaScript = strJavaScript +"window.setTimeout('" + strUrl + "',2000);";
    strJavaScript = strJavaScript + "</script>";