Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

HOW TO: Display a Random Quote When a Page Is Loaded in FrontPage 2000


View products that this article applies to.

This article was previously published under Q197958

↑ Back to the top


Summary

This article contains sample JavaScript code that displays a random quote when the HTML document is loaded.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. For this JavaScript code to function, you must type it manually in the HTML code. The FrontPage user interface does not provide a means to insert JavaScript code between the closing <\HEAD> tag and the opening <BODY> tag.

Editing the HTML Code

  1. To view the HTML code, start FrontPage, Change to the page view, and click the HTML tab.
  2. Insert the following JavaScript code between the </HEAD> tag and the <BODY> tag in the HTML document:
          <SCRIPT LANGUAGE="JScript">
          <!--
    
          function DisplayQuote() {
           // Build an array of quotes
           var quote = new Array(20)
           quote[0] = "Quote example 1"
           quote[1] = "Quote example 2"
           quote[2] = "Quote example 3"
           quote[3] = "Quote example 4"
           quote[4] = "Quote example 5"
           quote[5] = "Quote example 6"
           quote[6] = "Quote example 7"
           quote[7] = "Quote example 8"
           quote[8] = "Quote example 9"
           quote[9] = "Quote example 10"
           quote[10] = "Quote example 11"
           quote[11] = "Quote example 12"
           quote[12] = "Quote example 13"
           quote[13] = "Quote example 14"
           quote[14] = "Quote example 15"
           quote[15] = "Quote example 16"
           quote[16] = "Quote example 17"
           quote[17] = "Quote example 18"
           quote[18] = "Quote example 19"
           quote[19] = "Quote example 20"
    
           // Determine today's date and pick a quote
           // based on the second.
           var now = new Date()
           var sec = now.getSeconds()
           alert("Today's Quote:\r" + quote[sec % 20])
          }
    
          //-->
          </SCRIPT>
    						
  3. Add a OnLoad directive to the BODY tag to run the Jscript.

    For example, the <BODY> tag should appear as follows:

    <BODY OnLoad="DisplayQuote()">

↑ Back to the top


Keywords: KB197958, kbfaq, kbhowtomaster, kbhowto

↑ Back to the top

Article Info
Article ID : 197958
Revision : 2
Created on : 6/18/2005
Published on : 6/18/2005
Exists online : False
Views : 387