html中定义表头也可以刷新的效果
但是很不友好
<Meta http-equiv="refresh" content="60">
一般用ajax实现这个效果
var xmlHttp1;//xmlHttpRequest对象
var fileuploadURL;//下载地址
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp1 = new XMLHttpRequest();
}
}
function startRequest(url,fileuploadurl) {
fileuploadURL = fileuploadurl;
delRow();
createXMLHttpRequest();
xmlHttp1.onreadystatechange = handleStateChange;
xmlHttp1.open("POST",url,true);
xmlHttp1.send(null);
}
function handleStateChange() {
if(xmlHttp1.readyState == 4) {
if(xmlHttp1.status == 200) {
var respText = xmlHttp1.responseText;
parseString1(respText);
}
}
}
function parseString1(str){
var attachmentArray1 = str.split("^");
attachmentArray1.splice(attachmentArray1.length-1,1);
var t=document.getElementById("attachSpan1");
var tRow = null;
for(var i=0;i<attachmentArray1.length;i++){
var itemStr =attachmentArray1[i];
var innerArray = itemStr.split("_");
tRow = t.insertRow(1);
tRow.className="tr_common_main_1";
var tCell0 = tRow.insertCell(0);
var tCell1 = tRow.insertCell(1);
var tCell2 = tRow.insertCell(2);
tCell2.innerHTML="<input align ='center ' type='button' onclick='invoke("+innerArray[0]+")' value='删 除'>";
tCell2.align="center";
tCell0.innerHTML = "<a title='点击下载' href='"+fileuploadURL+"?downId="+innerArray[0]+"'>"+innerArray[1]+"."+innerArray[2]+"</a>";
tCell0.align="center";
tCell1.appendChild(document.createTextNode(""+innerArray[3]));
tCell1.align="center";
}
}
<body onload=clearName();setInterval("checkValue();",3000);>
这样实现比较友好
原文链接:https://www.f2er.com/ajax/163221.html