62,046
社区成员
发帖
与我相关
我的任务
分享
首页代码如下,我想每隔5秒刷新一次,用AJAX控件timer不好用,只能用JS,没用过JS,所以特此请教,解决分全给!
新手,请给出在哪加入语句,谢谢!
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<b>
<font color="#000099" size="5" >全部设备列表</font>
</b>
</center>
<hr color=blue width="800"></hr>
</div>
<center>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="5000">
</asp:Timer>
<table width="90%">
<tr valign="top">
<td>
<asp:GridView ID="gvInfo" runat="server" AutoGenerateColumns="False" Width="90%" CellPadding="3" AllowPaging="True" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" PageSize="2" EmptyDataText="无可显示数据。">
<Columns>
<asp:BoundField DataField="sysName" HeaderText="设备名称">
<ItemStyle HorizontalAlign="Center" Width="6%" />
<HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="deviceOnlineStatus" HeaderText="设备在线状态">
<ItemStyle HorizontalAlign="Center" Width="6%" />
<HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ResourceType" HeaderText="设备类型">
<ItemStyle HorizontalAlign="Center" Width="6%" />
<HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ipAddress" HeaderText="IP地址" >
<ItemStyle HorizontalAlign="Center" Width="6%" />
<HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<RowStyle BackColor="#E7E7FF" BorderColor="White" ForeColor="Black" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<HeaderStyle BackColor="Desktop" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
<PagerSettings Visible="False" />
<EmptyDataRowStyle BackColor="#E7E7FF" BorderStyle="None" ForeColor="Black" />
</asp:GridView>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</center>
</form>
</body>
</html>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick">
</asp:Timer>
<asp:Label ID="lblTimer" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</form>
protected void Timer1_Tick(object sender, EventArgs e)
{
lblTimer.Text = DateTime.Now.ToString();
}
<meta http-equiv="Refresh" content="1000;URL=...">
放在<head></head>标记内,
content="1000;URL=...
指.每秒定时刷新 内容为URL地址的页面
<script>
var hwd;
var intSec = 60;
function reHandle()
{
if(intSec==0)
window.location.reload();
else
{
intSec--;
}
hwd = setTimeout(reHandle,1000);
}
reHandle();
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js实现定时自动刷新功能</title>
</head>
<body>
<input type="button" value="reflesh" onclick="reflesh();"/>
<select id="times">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
</select>
<script>
var t = document.getElementById("times");
function reflesh()
{
alert("出发刷新操作!"+t.value);
document.location.reload();
}
setTimeout("reflesh()",t.value*1000);//每10秒钟刷新一次
</script>
</body>
</html>
<script>
setInterval("startRequest();",1000);//最后一个参数是时间间隔,自己该,单位毫秒
function startRequest()
{
window.location=this.location.href;
}
</script>