WebDeveloper.com �: Where Web Developers and Designers Learn How to Build Web Sites, Program in Java and JavaScript, and More!   
Web Developer Resource Directory WebDev Jobs
Animated GIFs
CSS Properties
HTML 4.01 Tags
Site Management
WD Forums

    Web Video
    Expression Web



    Forum, Blog, Wiki & CMS

 Site Management
    Domain Names
    Search Engines
    Website Reviews

 Web Development
  Business Issues

    Business Matters

    The Coffee Lounge
    Computer Issues

DR. WEBSITE: Differences Between GIFs and Java Animations; Automatic Date and Time Displays

By David Fiedler and Scott Clark

Dear Dr. Website®: I notice many banner ads are animated GIFs, rather than Java animations. Is there a difference in how they load or the system resources they take to run?

Some of it is simply a matter of reaching more viewers. Not all users are using Java- enabled browsers; however, most are using browsers that are capable of displaying animated GIFs. Java applets are more resource-intensive and usually take longer to load than animated GIFs.

Most applets with animation require actual image files anyway, and they, too, are a part of the download process. This is one reason why you see so many animated GIFs (versus Java applet animations). However, if the Java applet loads fast, and has a nice effect, there's no reason not to use it. Just make sure you place an alternate image tag inside the applet tag for those without Java, i.e.:

 <APPLET CODE="fx.class" WIDTH=200 HEIGHT=100> <IMG SRC="fx.gif"> </APPLET> 
This way, those viewers will see an alternate image instead of a blank area where the applet should be.

Dear Dr. Website®: In HTML, JavaScript, or CGI, is there a code to use that instructs the page to automatically display the date and time that page was last updated (e.g., Updated <&date,&time>) and to have the page show it in this form: Updated June 25, 1997, 5:25 p.m.?

You can use the JavaScript date functions and the document.lastModified properties to get the date and print it out. However, with document.lastModified, the date will be in general date format, i.e., 12/22/95 20:18.

You can use the other date functions, such as getYear(), getMonth(), etc., to extract the year, month, day, hour, and minute. Then you'll have to parse the month and the hour to get it into a long date format, i.e., March 12, 1997, 5:10 instead of 03/12/97, 17:10. Here's the code to do it:

 <SCRIPT LANGUAGE="JAVASCRIPT"> <!--// function showdate(){ revdate = new Date(document.lastModified); year = revdate.getYear(); month = revdate.getMonth() + 1; day = revdate.getDate(); hour = revdate.getHours(); min = revdate.getMinutes(); var mon; var hor; if(hour>12) hor=hour-12; if(month==0) mon="January"; if(month==1) mon="January"; if(month==2) mon="February"; if(month==3) mon="March"; if(month==4) mon="April"; if(month==5) mon="May"; if(month==6) mon="June"; if(month==7) mon="July"; if(month==8) mon="August"; if(month==9) mon="September"; if(month==10) mon="October"; if(month==11) mon="November"; if(month==12) mon="December"; document.write("<FONT SIZE=4 FACE=\"ARIAL\"><B>Updated " +mon + " " +day + ", " + "19"+year + " at " +hor + ":" +min + "</B></FONT>"); } //--> </SCRIPT> 
The code below can then be added to your page to produce the following output:
 Updated September 29, 1997 at 8:40 <BODY> <SCRIPT LANGUAGE="JAVASCRIPT"> <!--// showdate(); //--> </SCRIPT> </BODY> 


Webdeveloper.com's home page

Back to Home Page

Keywords: html, site_management
Date: 19970929

HTML5 Development Center

Recent Articles