php实现刷新不刷屏的效果?
php实现刷新不刷屏的效果?我有一个center.PHP页面是套在main.php主页面中的。我想实现center.php定时刷新 但屏幕不要出现闪烁的效果。要实例谢谢。我QQ:200925150追问:可以用个实例么,说明白点,我是新手
追问:可以用个实例么,说明白点,我是新手
答案:我现在用的正确代码采用的是AJAX<script type="text/javascript">
//更多多ajax资料 http://www.94x.net/so.php?word=ajax
function createRequest()
{
var request = false;
try
{
request = new XMLHttpRequest();
} catch (trymicrosoft)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed)
{
request = false;
}
}
}
if (!request)
{
alert("Error loading AJAX");
} else
{
return request;
}
}var req = createRequest();
function doCounter()
{
var url = "?go=show&time"+new Date().toString();
if (req)
{
req.open("GET", url, true);
req.onreadystatechange = doCounterHandle;
req.send(null);
}
}function doCounterHandle()
{
if (req.readyState == 4 && req.status == 200)
{
var msg = req.responseText;
objpic = document.getElementById("viewCounter");
objpic.innerHTML = msg;
}
}function doLoop() {
doCounter();
setTimeout("doLoop()",0);
}doLoop();
</script>
<div id="viewCounter" align="center">ajax请求中...</div>
function ref(){
//alert(document.frames["cli"]);
setTimeout('ff()', 3000);
}
function ff(){
document.frames["cli"].location=location;
}用ajax 来实现
安装jquery
$('#aaaa').load('你的页面就可以了');aaaa是<div id="aaa"></div>
function ref(){
//alert(document.frames["cli"]);
setTimeout('ff()', 3000);
}
function ff(){
document.frames["cli"].location=location;
}這方法不錯 !
至於出現閃爍 應該是只有包含center.PHP的區塊才有 不太明顯
得用AJAX!!