FP2000: How to Display a Random Quote When a Page Is Loaded

ID: Q197958


The information in this article applies to:
  • Microsoft FrontPage 2000


SUMMARY

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


MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/supportnet/refguide/

Problems produced by editing the Hypertext Markup Language (HTML) code that FrontPage generates will not be resolved by Microsoft Technical Support. This HTML code sample is provided as a convenience for authors seeking to extend FrontPage's capabilities. For more information about writing HTML, see the following Web site:

http://www.microsoft.com/workshop/author/newhtml/default.htm.

WARNING: ANY USE BY YOU OF THE HTML PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this HTML "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

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.

To edit the HTML code, follow these steps:

  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()">


Additional query words: JavaScript kbscript kbcode

Keywords :
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 7, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.