Click to See Complete Forum and Search --> : a link that will give a page for that day...?
zebedeus
02-04-2003, 08:00 PM
I am looking for a way to make a (javascripted) link that will open "calender-0101.htm" on january 1, and "calender-0102.htm" on january 2, etc.
I found a script (see text-file attached) where this is done by the days of the week, but I can't seem to make the right adjustments.
Any idea...?
Thanks,
Zebedeus
khalidali63
02-04-2003, 08:08 PM
Not much to do there.
get todays date using
var today = new Date();
the above will return date in this format
Tue Feb 4 19:06:15 MST 2003
from here you only have to parse the date string and create the date part of the page name
"0101"
once that is done
use the following line to open the correct page
document.location.href ="calendar-"+date+".html"
cheers
Khalid
zebedeus
02-04-2003, 08:18 PM
Khalidali63
I think you answered within 15 minutes???
And I've been stuck with this for quite a few days :)
I'll try what you suggested
Thanks
Zebedeus
Sergey Smirnov
02-04-2003, 08:19 PM
I hope, it will saves additional 10 min:
var today = new Date();
var day = today.getDate();
var month=today.getMonth()+1;
var date=(month<10?"0"+month:month)+(day<10?"0"+day:day);
document.location.href ="calendar-"+date+".html"
zebedeus
02-04-2003, 09:00 PM
Still...
How does the actual link look like then...?
I think I'll get that script right now
but suppose i am on page1.htm
and on it is a link that should automatically
open the page "calender-xxxx.htm"
xxxx being the date (mm/dd)
<a href="javascript.........?
But the answers fly around in minutes here
so who knows...
Thanks, all
Zebedeus
khalidali63
02-04-2003, 09:07 PM
in that case you do not need to get the current page's location rather follow the remaining routine and create the page link as mentioned in the above psot.
cheers
Khalid
Sergey Smirnov
02-04-2003, 09:35 PM
You have not to use <a href="javascript......... with this script. It is ready to go script.
Sergey Smirnov
02-04-2003, 09:40 PM
Instruction:
1. rename newspage.txt to newspage.htm
2. put it in the same directory where your "calender-xxxx.htm" files are located
3. From any other pages you can make a link:
<a href=newspage.htm>News of the Day</a>
When user clicks on this link, he/she will be redirected to the current news.
Note: new Date() returns the local date of the browser. It may be vary with your server site time.
zebedeus
02-05-2003, 03:20 PM
Brilliant solution, Sergey
Thank a lot !!!
Case closed
Zebedeus