|
|
Today's The Day
You are here: irt.org | Articles | JavaScript | Date and Time | Today's The Day Published on: Thursday 1st January 1998 By: Martin Webb IntroductionThis article brings together the last few articles, to produce a page that shows all data regarding any date entered: full date, age, events, birthstone, Zodiac star sign, Chinese year, lottery numbers and random colors. As an added extra it also includes images of birthstones, zodiac star sign and the animal associated with the Chinese year. It also demonstrates how to use the output page in three different options, framed, non-framed and stand alone. Adding ImagesAdding a variable image to a document whilst it is being rendered is fairly simple:
All that is required is the imageName. The three different types of images used within this example are displayed as follows:
All the images are within sub-directories of the data directory. All the images have the height, width and alt attributes defined (all good practice). The names of the images are defined by the variable, months[month], months[starsign] and chineseyear.toLowerCase() with the addition of .gif. All these varibles have been covered in recent articles, so I won't go into any detail here. Stand alone VersionIn the previous article Blind Date we described how to code a document to accept its input data from either the parent frame, or from the location search property:
To add a stand alone version, i.e. where there is no input data, requires a default input. The following script first checks if the location of the current document is not equal to the location of the parent frame, if they are not the same then the current document is within a frameset. In which case we'll use the data held in the parent frame. If they are the same, then the length of the location search property is checked. If its not zero, then the data held within the search string is used. If its zero, then it defaults to the local data:
The stand alone version also shows the input form, otherwise there is no way to change the date :-) Now that we've created a stand alone version, we can include it in a popup window:
Working ExampleTry this example which brings everything together from the last ten articles: frame version, non frame version, stand alone version, popop version. Note: The non frame version will not work offline in MSIE version 3.x. Source CodeYou can view the source code of the four components: Feedback on 'Today's The Day'
View the profile on Martin Webb and the list of other Articles by Martin Webb. |
-- div -->
|