-Code aktualisiertRefresh iframe, wenn keine Benutzeraktivität
<!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>
Ich habe einen Iframe, die ich aktualisieren möchten, wenn es keine Benutzeraktivität ist. Im Moment versuche ich, dies zu verwenden:
<!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>
Aber es scheint nicht zu funktionieren. Gibt es einen besseren oder zumindest einen richtigen Weg, dies zu tun?
Nach der Aktualisierung meines Codes habe ich immer noch Probleme damit, den Iframe nicht neu zu laden. Könnte die src-Verbindung überhaupt etwas damit zu tun haben? – shinjuo