简体   繁体   English

根据当地月份和日期重定向Index.html页面

[英]Redirect Index.html page based on local month and day

My website "skytamer.com" currently has 366 verions of the index.html page that I manually load each evening. 我的网站“ skytamer.com”目前拥有index.html页面的366个版本,我每天晚上手动加载。 The 366 versions are stored in the in the following directory: 366个版本存储在以下目录中:

www.skytamer.com/date/0101.html. www.skytamer.com/date/0101.html。

The 366 files, are denoted as ie, 0101.html (January 1), 0601.html (June 1) etc., one for each day of the year. 366个文件分别表示为0101.html(1月1日),0601.html(6月1日)等,一年中的每一天。

I need a script that will automatically redirect the index.html page based on the computer's timestamp local month and day. 我需要一个脚本,该脚本将根据计算机的本地本地时间戳和日期自动重定向index.html页面。

Example, the Earth keeps turning and 6 June comes around. 例如,地球不断旋转,6月6日到来。 The "index.html" page should then load "www.skytamer.com/date/0601.html" as the new "index.html" page. 然后,“ index.html”页面应将“ www.skytamer.com/date/0601.html”作为新的“ index.html”页面加载。

Can this be done? 能做到吗?

<meta http-equiv="refresh" content="5;URL='http://example.com/'"> combined with a simple script that checks the date. <meta http-equiv="refresh" content="5;URL='http://example.com/'">结合了用于检查日期的简单脚本。

Keep in mind that timezones exist, so you might want grab the time from the server if you have server side scripting available. 请记住,时区存在,因此,如果有可用的服务器端脚本,则可能要从服务器获取时间。

The script: 剧本:

function getPageToday() {
var today = new Date();
var day = String(today.getDate());
var month = String(today.getMonth() + 1);
if (day.length === 1) {
    day = '0' + day;
}
if (month.length === 1) {
    month = '0' + month;
}
var page = month + day + '.html';
return page;

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM