日期:2014-05-19  浏览次数:20451 次

页面延迟运行(保证延迟前代码的运行),谢谢!
我在CSDN上搜索过帖子怎样让代码延迟运行,但得到的结果都是使用System.Threading.Thread.Sleep()来实现的。但这样有个问题,就是一旦加入了这行语句,所有的操作都会被延迟,尽管有些操作是这条语句之前的。

我的问题简而言之就是:
1、先在页面上输出信息:
      Response.Write( "...... ");
2、然后延迟2秒钟。
      ???
3、然后跳转到另外一个页面。
      Response.Redirect( "~/... ");

如果用System.Threading.Thread.Sleep()的话,就不能看到Response.Write的内容了,请大家帮忙!

谢谢!

------解决方案--------------------
前台处理

<head>
<meta http-equiv=refresh content= "3;url=http://www.csdn.com ">
</head>
注意:content=3后面是分号(;)

------解决方案--------------------
LZ 要实现的是客户端延时,而 System.Threading.Thread.Sleep() 实现的是 Server 端延时,

完全是驴唇不对马嘴!哈

许多站点都有注册后,先显示注册成功页面,3秒后自动调转至登陆页的效果,都是用 JS 实现的!

对了 CSDN 的收藏功能就是 2 秒后自动关闭,代码如下,LZ 自己改改吧!

<html>
<head>
<title> CSDN技术网摘 -- wz.csdn.net </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<link rel= "StyleSheet " href= "/main.css " type= "text/css " media= "screen ">

<script type= "text/javascript ">
function closeIt() {
self.close();
}
function doClose() {
setTimeout( "closeIt() ", 2000);
}
</script>
</head>

<body bgcolor= "white " onLoad= "doClose(); ">
<table width= "100% " height= "75% " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr> <td valign= "center ">
<center>

<table width= "300 " class= "greenBox ">
<tr> <th> 成功啦! </th> </tr>
<tr> <td align= "center ">
<span class= "success "> 网页成功保存. </span> <br/> <br/>
<a href= "/my " target= "_blank "> 进入我的网摘管理 </a>
</td> </tr>
</table>

</center>
</td> </tr>
</table>
</body>
</html>