this is a bit of an odd question. Change webpage at end month
I need a webpage to only stay live until end July but I am away at this time. I have another separate 'page offline' html page ready.
Is it possible to swap inside a new index.html (I have experimented using code below with limited success) to use thedate.getUTCMonth();
to change/switch to other webpage ?
I can get simple line of code to change (as below) a header within 1 page but not an entire html webpage, its too delicate and falls over. I thought a new 3rd index page that has condition if month > 6 then display index1.htm or if month < 7 show index2.htm
but I am stuck to make it work if it is even possible ?
my best effort so far (I am not a coder) is this which works for a simple header but not much more.
<head>
<script type="text/javascript">
var thedate = new Date();
var month = thedate.getUTCMonth();
function changepage()
{
// return TRUE if it's - well depends on setting for greater or less than
if (month > 7)
{
return true;
}
return false;
}
</script>
</head>
<body>
// less than 7 you get this
<h1>The page header and blurb</h1>
<script type="text/javascript">
if (changepage()) {
document.write("<h2>html in here for index page 1</h2>");
} else {
document.write("<h2>html for index page 2</h2>");
}
</script>
<p>
generic footer info
<a href="http://a_web_page.com/">Randon page link</a>
</p>
</body>
</html>
thank you in advance
CodePudding user response:
You should do tasks like this on server side. What if an user hase turned of javascript?
In php you can do it quite easy:
<?php
if (date(n) > 6) {
include 'index1.html';
} else {
include 'index2.html';
}