From this page I got a great answer, see below the code. One problem occurs for me.
This script is checking itself. The code is in index.html and it will check if there are changes on index.html. If there are changes, it should refresh itself. It all works, but it stays in the same condition.
So if you change the file once, it will loop saying 'the site has been modified' and refresh. Does anbody know how to solve this?
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
var checkUrl="index.html";
var firstCheck = false;
window.setInterval("checkForUpdate()", 1000);
function checkForUpdate() {
$.ajax(checkUrl, {
ifModified : true,
type : 'HEAD',
success : function (response) {
if(firstCheck === false) {
firstCheck = true;
return;
}
$('#output').html('the site has been modified');
}
});
}
</script>
</head>
<body>
<div id="output">Not Modified</div>
</body>
</html>