function dateString(past)
{
var days = new Array();
days[0]=31; // J
days[1]=28; // F
days[2]=31; // M
days[3]=30; // A
days[4]=31; // M
days[5]=30; // J
days[6]=31; // J
days[7]=31; // A
days[8]=30; // S
days[9]=31; // O
days[10]=30; // N
days[11]=31; // D
var d = new Date();
var dow = d.getDay();
var dom = d.getDate();
var month = d.getMonth();
var year = d.getYear();
if (dow == 6)
dom -= 1;
if (dow == 0)
dom -= 2;
if (dom<1>
month -= 1;
if (month<1>
year -= 1;
month = month+12;
}
dom = days[month-1];
}
if (dom<1>
if (month<1>
document.write('<a href="http://www.kslegislature.org/agstat/'+year+'/hs'+dom+month+'.pdf">'+dom+'/'+month+'/'+year+'</a> ');
}
dateString(0);
dateString(1);
dateString(2);1>1>1>1>function dateString(past)
{
var days = new Array();
days[0]=31; // J
days[1]=28; // F
days[2]=31; // M
days[3]=30; // A
days[4]=31; // M
days[5]=30; // J
days[6]=31; // J
days[7]=31; // A
days[8]=30; // S
days[9]=31; // O
days[10]=30; // N
days[11]=31; // D
var d = new Date();
var dow = d.getDay();
var dom = d.getDate();
var month = d.getMonth();
var year = d.getYear();
if (dow == 6)
dom -= 1;
if (dow == 0)
dom -= 2;
if (dom<1) {
month -= 1;
if (month<1) {
year -= 1;
month = month+12;
}
dom = days[month-1];
}
if (dom<10) dom = '0'+dom;
if (month<10) month = '0'+month;
document.write('<a href="http://www.kslegislature.org/agstat/'+year+'/hs'+dom+month+'.pdf">'+dom+'/'+month+'/'+year+'</a> ');
}
dateString(0);
dateString(1);
dateString(2);<script type="text/javascript">
function openToday() {
// Get year, month, and day right now
var now = new Date(),
year = now.getFullYear().toString(),
// Months are indexed from zero
month = now.getMonth() + 1,
day = now.getDate(),
weekday = now.getDay();
if ((weekday == 0) || (weekday == 6)) {
// It's the weekend
return false;
}
// Ensure that month and day have two digits
(month < 10) && (month = '0' + month.toString());
(day < 10) && (day = '0' + day.toString());
// Construct the URL
var url = (
'http://www.kslegislature.org/agstat/' +
year + '/hs' + month + day + '.pdf'
);
// Go there
window.location.href = url;
}
</script>
<input type="button" value="Open today's page" onclick="openToday()"><a id="todaysLink">Open today's page</a>
<script type="text/javascript">
// Get year, month, and day right now
var now = new Date(),
year = now.getFullYear().toString(),
// Months are indexed from zero
month = now.getMonth() + 1,
day = now.getDate(),
weekday = now.getDay();
if ((weekday == 0) || (weekday == 6)) {
// It's the weekend
document.getElementById('todaysLink').href = (
'javascript:alert("Sorry, nothing on weekends.")'
);
return;
}
// Ensure that month and day have two digits
(month < 10) && (month = '0' + month.toString());
(day < 10) && (day = '0' + day.toString());
// Construct the URL
var url = (
'http://www.kslegislature.org/agstat/' +
year + '/hs' + month + day + '.pdf'
);
// Attach it to the link
document.getElementById('todaysLink').href = url;
</script>document.getElementById('todaysLink').href = (
'javascript:alert("Sorry, nothing on weekends.")'
);...you could do:
document.getElementById('todaysLink').innerHTML = (
'Sorry, nothing on weekends.'
);
...which would make the link into a non-clickable message.
get date
if date.day is 6, date = date - 1
if date.day is 7, date = date - 2
end if
link = string + date.year + "/hs" + date.month + date.date + ".pdf"
document.write(link)
or something like that.
posted by The Michael The at 10:24 AM on January 16, 2010