Basic Web Design
 
Intermediate Web Design
 
Advanced Web Design
Web Design Program
 
Scripting Database
 
 
 
  Home
JavaScript
  Today's Date
  Dropdown Menu
  Mouse Over
  Status Bar
  Status Runner
  Background Color
  Script Tester
  Mini-Windows
  Cookies
  Expiration
Java Applets
Available CGI
META Tags
Server Elements

Expiration of items on a page

   
 

When you add something to your site or modify something, you usually place a new icon next to it so that visitors can easily find it. The idea is to display the icon for a fixed period of time and then remove it. However, if you are constantly modifying your site or if you have a large number of pages, then keeping track of all the new icons becomes very difficult.

Using JavaScript, it is possible to program your HTML to display the new icon only for a certain period of time. You write a JavaScript function which compares the current date with the expiryDate and inserts the new icon only if the current date has not exceeded the expiryDate. Here is the code :

    

Usually, functions like this are defined between the <HEAD> and </HEAD> part of the HTML. Change the new.gif to the name of your image and modify the WIDTH and HEIGHT attributes accordingly. Now where ever you want to put the icon, insert the following code :

    

  The icon will be shown up to the date you specify as the parameter for newItem().

 

 

 

 

 

 

 
Give us your Questions of Comments!!!