What I am trying to do is after 59 minutes reload the page and after the page is reload display a message stating that the page has been reload. Then set the timer again and repeat the same thing. I am having trouble with hiding and displaying the alert and also a little lost on the logic after the first refresh. This is what I have so far:
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.Bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jQuery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<script language="JavaScript"> <!--
function checkRefresh()
{
if( document.refreshForm.visited.value == "" )
{
// This is a fresh page load
document.refreshForm.visited.value = "1";
document.getElementById(a).style.visibility="hidden";
window.setTimeout(myalertfunction, 59 * 60 * 1000)
}
else
{
document.getElementById(a).style.visibility="visible";
// This is a page refresh
window.setTimeout(myalertfunction, 59 * 60 * 1000)
}
} -->
</script>
</head>
<body onLoad="JavaScript:checkRefresh();">
<div class="alert alert-info fade in" id="a">
<a href="#" "class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Info!</strong> This Page has been reloaded!
</div>
<form name="refreshForm">
<input type="hidden" name="visited" value="" />
</form>
</body>
</html>
Try using <meta>
tag
<meta http-equiv="refresh" content="5; URL=http://www.example.com/test.html">
OR JavaScript's setTimeout()
setTimeout(function(){
window.location.reload(1);
},60000)
Maybe you can try something like this :
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.Bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<script language="JavaScript">
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
$(document).ready(function() {
var visitedValue = getParameterByName('visited',window.location.href);
if (visitedValue === '1') {
$('#a').show();
}
setTimeout(function(){
$('#visited').val('1');
$('#refreshForm').action = window.location.href;
$('#refreshForm').submit();
},3540000);
});
</script>
</head>
<body>
<div class="alert alert-info fade in" id="a" style="display:none;">
<a href="#" "class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Info!</strong> This Page has been reloaded!
</div>
<form name="refreshForm" id="refreshForm">
<input type="hidden" id="visited" name="visited" value="" />
</form>
</body>
</html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.