JavaScript
New Item
Back


Displays an image if specified date is newer than todays date. This script can be used to mark links, stories or any item you want to flag as new on your web pages. It will display an image up to a date you specify. If you want to mark items as new up to 30 days after they were added to your web page set the specified date to 30 days after the date added.

There are two parts to this script. Part 1 is placed between the HEAD tag of your document. Part 2 is placed between the BODY tags where ever you want the image to display. Change the numbers between the parentheses to the date you want the new item to expire.

Example:

Items marked as new were added with in the last 30 days!
New link 1
New link 2
Old link

Place this code between the HEAD tags of your document.
Part 1 Code:

<SCRIPT LANGUAGE="JavaScript"> <!-- BEGIN HIDING function newitem(expire) { tempdate = new Date() var mon = tempdate.getMonth()+1 var day = tempdate.getDate() var year = tempdate.getYear() if(mon < 10){ mon = "0" + mon; } if(day<10){ day = "0" + day; } today = year +""+ mon +""+ day if (today < expire){ document.write("<IMG SRC='./images/new1.gif' " + "%>") } } // END HIDING --> </SCRIPT>



Place this code between the BODY tags of your document where ever you want the image or text displayed.
Part 2 Code:

Change the numbers between the parentheses to the date you want the new item to expire. Date must be formatted as yearmonthday. Single digit numbers must have a zero in front

<SCRIPT LANGUAGE="JavaScript"> <!-- BEGIN HIDING // date must be YearMonthDay // numbers only // single digit numbers must have a zero in front // ex.May 6 1997 would be 970506 newitem(980508); // END HIDING --> </SCRIPT>


Rate this script
Excellent Acceptable Poor
Comment: