站内搜索: 请输入搜索关键词

当前页面: JAVA 编程资料牛鼻论坛AJAX & JavaScript 技术→刷新网页的程序代码

刷新网页的程序代码

发表新主题   回复此主题

第1楼 2007-03-01 00:04 jou1204 写道:

刷新网页的程序代码


用JavaScript实现网页的刷新代码,当进入一个网页时实现自动刷新页面

第2楼 2013-08-31 12:44 Robot :

刷新网页的程序代码 相关


第3楼 2007-03-01 00:19 Acts 29 写道:

其实可以调用<metq>
<head>
<meta http-equiv="refresh" content="5">
</head>

JavaScript方法:
<script>
setInterval("window.location.reload()",1000)//1000表示1秒钟
</script>
或用:
setTimeout("location.reload()",1000)

或:
<script>
function aa(){document.location.reload()}
setTimeout(aa,2000)
</script>


第4楼 2007-03-02 12:24 Sandrer 写道:

使用Microsoft.XMLHTTP组件可以轻易做到无刷新。
首先你编写一个普通的*.htm文件(这里叫它A)
再编写一个处理页(这里叫它B)
最后要编写一个过程页(这里叫它C)

首先先给出C页的代码:
(注:页面C为VBScript文档,即*.vbs文件,为什么要用vbs后面解释)
Function SendCommand(Action, Method, Property)
  strExecuteURL = "B.asp" '这里换上你的处理页名
  If Action <> "" Then strExecuteURL = strExecute & "?Action=" & Action
  On Error Resume Next
  Set oReq = CreateObject("MSXML2.XMLHTTP") '如果这个不能创建,试试"Microsoft.XMLHTTP"
  If Err Then
    Err.Clear
    Set oReq = Nothing
    MsgBox "服务器不支持无刷新组件。"
    SendCommand = ""
    Exit Function
  End If
  If UCase(Method) <> "POST" And UCase(Method) <> "GET" Then Method = "POST"
  oReq.open Method, strExecuteURL, false
  oReq.setRequestHeader "Content-Length", Len(Property)
  oReq.setRequestHeader "CONTENT-TYPE", "application/x-www-form-urlencoded"
  oReq.send Property
  strReturn = oReq.responseBody
End Function

A页的代码(此页为普通的HTM文件,即*.htm或*.html:
<html>
<head>
<script src="C.vbs"></script>
<title>无刷新示范</title>
</head>
<body>
<label id="Content"> </label>
<script language=javascript>
var TimeOut = null;
function systemTime(){
document.all.Content.innerText = SendCommand("GetTime", "", "");
}
TimeOut = setTimeout(systemTime(), 1000);
</script>
</body>
</html>

页面B的代码(我只会ASP,所以这个页面的代码为ASP代码,即*.asp,过程页调用的处理页就是这个)
<%
Action = Request("Action")
Select Case Action
  Case "GetTime"
    Response.Write Now()
    Response.End()
End Select
%>



无刷新处理基本就是这样,其他的函数或者判断你可以自己添加进去,有不明白的可以发短信问我!


发表新主题   回复此主题