【发布时间】:2011-06-03 12:28:20
【问题描述】:
更新代码
<!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 content="text/html; charset=utf-8;" http-equiv="Content-Type;" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
//This goes into a script tag in your head tag
var docTimeOut;
function bodyTimeOut() {
docTimeOut=setTimeout("updateFrame();",10000);
}
function resetTimeOut() {
//alert('reset!');
clearTimeout(docTimeOut);
bodyTimeOut();
}
function updateFrame() {
//Loads the page's html into the div
//Uncomment this in your actual code
$.get('https://www.creator.zoho.com/somePage/', function(data) {
$('openPrintRun').html(data);
});
//alert('update!');
}
//This function runs when the DOM has finished loading
$(function() {
bodyTimeOut();
//This binds the resettimeOut function the click, mousemove and mouseover events of the div
$('#openPrintRun').bind('click mousemove mouseover', resetTimeOut);
});
// -->
</script>
<title>Untitled 1</title>
</head>
<body>
<div class="openPrintRun" style="height:250px; width:100%;">
</div>
</body>
</html>
我有一个 iframe,我想在没有用户活动时刷新它。目前我正在尝试使用它:
<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<script type="text/javascript">
var docTimeOut;
function bodyTimeOut()
{
docTimeOut=setTimeout(function(){location.reload();},1200);
}
function resetTimeOut()
{
clearTimeout(docTimeOut);
bodyTimeOut();
}
document.onload = bodyTimeOut;
document.getElementById('openPrintRun').onmouseover= resetTimeOut;
</script>
<title>Untitled 1</title>
</head>
<body>
<iframe id="openPrintRun" height='250px' width='100%' name='zoho-Open_Print_Runs' frameborder='0' scrolling='auto' allowTransparency ='true' src='somepage.html'></iframe>
</body>
</html>
但它似乎不起作用。有没有更好或至少正确的方法来做到这一点?
【问题讨论】:
-
更新我的代码后,我仍然无法重新加载 iframe。 src 链接与此有什么关系吗?
标签: html iframe android-activity timeout refresh