如果这看起来很愚蠢或多余,我道歉,我已经搜索和阅读了相关页面,但几乎不理解。
<?PHP include "newchat.php"; ?>我想每隔20分钟刷新一次newchat.php。(防止聊天超时。)
(即index.php)
<html>
<head>
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
// -->
</script>
</head>
<body onload="JavaScript:timedRefresh(10000);">
*chat script here*我认为我可能需要在每个模板页面上放入script/ajax,这会告诉浏览器只刷新该元素,但是我不理解这段代码,也不确定它是否适用。
感谢您的阅读和您可能提供的帮助。
发布于 2013-01-29 12:48:15
尝试将newchat.php文件放入页面上的iFrame中,而不是直接包含它。即:
<iframe src="newchat.php" id="chatFrame" frameborder="0" width="YOUR-WIDTH" height="YOUR-HEIGHT">然后,您可以在newchat.php文件中使用-刷新。或者,如果你想从每个页面控制它,你可以使用iframes id来控制来自父页面的刷新:
document.getElementById('chatFrame').contentDocument.location.reload(true);https://stackoverflow.com/questions/14570684
复制相似问题