10 个解决方案
#1
sample:
<head>
<script language="JavaScript" type="text/JavaScript">
<!--
var refreshtime = 1000;
function refpage(values){
document.getElementById("showmsg").innerHTML='<br>请稍候...';
var url = "refreshpage.asp?id="+values;
request.open("POST", url, false);
request.send();
//接收返回数据并更新内容
var retVal = request.responseText;
//数据处理(略)
//内容显示
document.getElementById("showmsg").innerHTML='......';
}
function focusbody(){
//本窗口被显示,定时发送信息;
refreshtime=90000;
show2()
}
function show2(){
if(refreshtime>0){
sendstate(1); //假设的参数
setTimeout("show2()",refreshtime); //循环计数
}
}
//-->
</script>
</head>
<body onload="focusbody();">
.....网页内容
</body>
</html>
#2
function focusbody(){
//本窗口被显示,定时发送信息;
refreshtime=90000;
show2()
}
这段是多余,从我做的网页上摘下来的,那个网页有处理 onblue,onfocus,onbeforeunload等事件的程序.
//本窗口被显示,定时发送信息;
refreshtime=90000;
show2()
}
这段是多余,从我做的网页上摘下来的,那个网页有处理 onblue,onfocus,onbeforeunload等事件的程序.
#3
定时器啊
#4
setInterval用这个也可以实现呀。
#5
Jquery ajax代码
$(function(){
timestamp = 0; //初始时间
updateMsg();
});
//主要代码
function updateMsg(){
$.post("chuli.aspx",{ time: timestamp }, function() {
//事件处理 });
setTimeout('updateMsg()', 4000); //4秒更新
}
#6
setTimeout或者setInterval来定时去执行函数
#8
学习中。。。
#9
你这样刷新的话,你的服务器能受的了吗。还是看看server pull相关的技术吧。
#10
<!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>无标题文档</title>
</head>
<div id="Clock" align="center" style="font-size: 12px; color:#000000"></div>
<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today, theday;
today = new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
theday = today.getYear()+"年" + [today.getMonth()+1]+"月" +today.getDate() + d[today.getDay()+1];
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = theday+xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<div id="Clock" align="center" style="font-size: 12px; color:#000000"></div>
<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today, theday;
today = new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
theday = today.getYear()+"年" + [today.getMonth()+1]+"月" +today.getDate() + d[today.getDay()+1];
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = theday+xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>
</body>
</html>
#1
sample:
<head>
<script language="JavaScript" type="text/JavaScript">
<!--
var refreshtime = 1000;
function refpage(values){
document.getElementById("showmsg").innerHTML='<br>请稍候...';
var url = "refreshpage.asp?id="+values;
request.open("POST", url, false);
request.send();
//接收返回数据并更新内容
var retVal = request.responseText;
//数据处理(略)
//内容显示
document.getElementById("showmsg").innerHTML='......';
}
function focusbody(){
//本窗口被显示,定时发送信息;
refreshtime=90000;
show2()
}
function show2(){
if(refreshtime>0){
sendstate(1); //假设的参数
setTimeout("show2()",refreshtime); //循环计数
}
}
//-->
</script>
</head>
<body onload="focusbody();">
.....网页内容
</body>
</html>
#2
function focusbody(){
//本窗口被显示,定时发送信息;
refreshtime=90000;
show2()
}
这段是多余,从我做的网页上摘下来的,那个网页有处理 onblue,onfocus,onbeforeunload等事件的程序.
//本窗口被显示,定时发送信息;
refreshtime=90000;
show2()
}
这段是多余,从我做的网页上摘下来的,那个网页有处理 onblue,onfocus,onbeforeunload等事件的程序.
#3
定时器啊
#4
setInterval用这个也可以实现呀。
#5
Jquery ajax代码
$(function(){
timestamp = 0; //初始时间
updateMsg();
});
//主要代码
function updateMsg(){
$.post("chuli.aspx",{ time: timestamp }, function() {
//事件处理 });
setTimeout('updateMsg()', 4000); //4秒更新
}
#6
setTimeout或者setInterval来定时去执行函数
#7
可以参考下这篇文章看看,
Ajax 随机刷新文字。
#8
学习中。。。
#9
你这样刷新的话,你的服务器能受的了吗。还是看看server pull相关的技术吧。
#10
<!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>无标题文档</title>
</head>
<div id="Clock" align="center" style="font-size: 12px; color:#000000"></div>
<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today, theday;
today = new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
theday = today.getYear()+"年" + [today.getMonth()+1]+"月" +today.getDate() + d[today.getDay()+1];
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = theday+xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<div id="Clock" align="center" style="font-size: 12px; color:#000000"></div>
<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today, theday;
today = new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
theday = today.getYear()+"年" + [today.getMonth()+1]+"月" +today.getDate() + d[today.getDay()+1];
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = theday+xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>
</body>
</html>