Goal: I currently have two local html files, one that redirects to the other. There are currently no checks in place to ensure the file I'm redirecting to does in fact exist beforehand. I'd like to redirect to the file only if it exists, and display a message if it doesn't exist yet.
Context: An app on my local machine outputs a fresh html file each day with a filename of today's date. Since I like to have this bookmarked but can't bookmark a dynamic url, I created this second html file (with a static filename) and bookmark that instead. This is where I'm at:
<!DOCTYPE html>
<html>
<head>
<title>Example Title</title>
<script>
function url(){
var date = new Date();
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
if(m < 10){m = '0' + m;}
if(d < 10){d = '0' + d;}
var date = y + m + d;
return 'file:///C:/Directory/html/example-' + date + '.html';
} window.open(url(),"_parent");
</script>
</head>
<body>
<p>Redirecting...</p>
</body>
</html>