•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,769 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,202 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 952 | Replies: 6 | Solved
![]() |
•
•
Join Date: Jan 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
I'm looking for a piece of code I used years ago to reveal a link at a later date. All I had to do was wrap the link in this piece of code and - presto - it revealed on the date and time that I wanted it to reveal.
I cannot remember if it was JavaScript or HTML. If you could offer any solutions I would be most grateful.
Thank you so much. I hope it's okay for me to cross-post in the HTML area.
Nancy
I cannot remember if it was JavaScript or HTML. If you could offer any solutions I would be most grateful.
Thank you so much. I hope it's okay for me to cross-post in the HTML area.
Nancy
JavaScript will do this. HTML can't make decisions based on the date. A Server side script would be even better because the user can't disable it the way they can JavaScript. Anyway, here you go:
JavaScript Syntax (Toggle Plain Text)
<script type="text/javascript"> var display_date=new Date('04/04/2008');//this will be the date the link starts displaying var currentTime = new Date(); var month = currentTime.getMonth() + 1; var day = currentTime.getDate(); var year = currentTime.getFullYear(); //get all dates in the same format var current_date = new Date(month +'/' + day + '/' + year); if(current_date>=display_date){ document.write('<a href="newlink.html">new link</a>'); } </script>
•
•
Join Date: Jan 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
JavaScript will do this. HTML can't make decisions based on the date. A Server side script would be even better because the user can't disable it the way they can JavaScript. Anyway, here you go:
JavaScript Syntax (Toggle Plain Text)
<script type="text/javascript"> var display_date=new Date('04/04/2008');//this will be the date the link starts displaying var currentTime = new Date(); var month = currentTime.getMonth() + 1; var day = currentTime.getDate(); var year = currentTime.getFullYear(); //get all dates in the same format var current_date = new Date(month +'/' + day + '/' + year); if(current_date>=display_date){ document.write('<a href="newlink.html">new link</a>'); } </script>
Okay, I'm an idiot. Well, I guess 'newbie' is kinder.
I'm tinkering with your code... if I want something to display tomorrow, is this enough editing (below)? I could tinker better if I could do it by minutes instead of days because then I wouldn't have to wait very long to see if I made a mistake....
JavaScript Syntax (Toggle Plain Text)
<script type="text/javascript"> var display_date=new Date('04/05/2008');//this will be the date the link starts displaying var currentTime = new Date('04/04/2008'); var month = currentTime.getMonth(); var day = currentTime.getDate() + 1; var year = currentTime.getFullYear(); //get all dates in the same format var current_date = new Date(month +'/' + day + '/' + year); if(current_date>=display_date){ document.write('<a href="http://www.whatever.com">Press Release</a>'); } </script>
Sorry, not sure how many lines need editing. I changed the date to '+1' and removed same from the 'getMonth' line.
Thank you for your patience.
Nancy
Last edited by NancyNancyNancy : Apr 4th, 2008 at 10:52 pm.
•
•
Join Date: Jan 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
I think I'll keep this thread open, because my question still involves 'code to control display of time-sensitive link'... now I would like to figure out how to HIDE a link at a certain time. Any suggestions greatly appreciated. And, if you would like, please feel free to refer me to any tutorials that you think would answer these types of questions. Thank you for your help, it's very kind of you.
Nancy
Nancy
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
access activation ads adsense aol api blodget blogger blogging blogs code code injection combo dani daniweb data debugging development dreamweaver dropdownlist epilepsy gdata google gpl griefers hackers javascript key link linux microsoft module net news openbsd product programming revenue rss serial source tags text time warner unit vista web wysiwyg xml
- memory management in wndows 2000 (Windows NT / 2000 / XP / 2003)
- Hijackthis report, I just don't know (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: spry grow effect and gallery demo
- Next Thread: Page visibility using javascript


Linear Mode