The Javascript Code for Inserting the Date Last Modified On

The Javascript Code for Inserting the Date Last Modified On thumbnail
The "date last modified" Javascript adds professionalism to websites.

Javascript code can add various kinds of functionality to a website. Visitors do not normally know when an owner updates a site. However, there is a Javascript code that will automatically give the date and time that a page was modified. By learning how to insert this code into a Web page, the owner can let visitors know when the page was last modified without the hassle of manually inserting the date for every website modification.

  1. Purpose

    • The "date last modified on" script is ideal for websites that frequently update information for visitors. For example, a sports site that updates scores can use this Javascript code to let visitors know when the game scores were last updated. This script also adds credibility to a site by letting visitors know that it is frequently updated with new information. A stale site that never changes can turn off visitors and harm the chance of repeat visitors. Thus, automatically adding the time and date for which a Web page was last modified keeps up the appearance of freshness.

    Code Text

    • Javascript codes are similar to HTML. They look like gibberish to the uninformed, but that is not a problem. When accurately placing the code in your website files, it works whether or not you understand the technical details of the script. The following lines of code comprise an actual Javascript to insert the date and "last modified on" message:

      <SCRIPT LANGUAGE="JavaScript">
      <!--
      var date
      date=document.lastModified
      document.write("Last Modified on "+date)
      // -->
      </SCRIPT>

    Modifying the Display

    • You may alter the "Last modified on" text to fit your own situation. Look inside the Javascript for those words and replace them with any message you like. For example, if you are updating stock market information, you could change it to "stock market prices last updated on." As usual, the script will automatically include the date and time for you. Make any desired text changes before placing the code in your website files.

    Deploying the Code

    • This "date modified on" Javascript goes inside the HTML body tags of the web page for which you want the message and date to appear. The body refers to the text that actually appears in browsers when someone visits the page. Look for the <body> and </body> tags in the HTML file and place the code in relation to the other text inside those body tags.

Related Searches:

References

  • Photo Credit Creatas/Creatas/Getty Images

Comments

Related Ads

Featured