Previous Example-|-Next Example-|-Return to Chapter Listing

Example 11.6:
Modifying String Appearances


This Web page has just called a function which displays the Prompt box. The user types some text in and clicks on OK. The function 'returns' this text. Then the script writes the text into the Web document, below:


These are the scripts we used. First, in the HEAD: <SCRIPT LANGUAGE="JavaScript"> <!-- function function1() { var sTypedText sTypedText = prompt("Type some text, then click on OK.", "") return sTypedText } //--> Later in the Web page: <SCRIPT LANGUAGE="JavaScript"> <!-- var sText sText = function1() document.write("You just typed: <P>" + sText) document.write("<BR> This is big: " + sText.big()) document.write("<BR> This is a link: " + sText.link("11-6.htm")) document.write("<BR> This is blinking text: " + sText.blink()) document.write("<BR> This is bold: " + sText.bold()) document.write("<BR> This is colored: " + sText.fontcolor("green")) document.write("<BR> This is italics: " + sText.italics()) document.write("<BR> This is small: " + sText.small()) document.write("<BR> This is strikethrough: " + sText.strike()) document.write("<BR> This is subscript: " + sText.sub()) document.write("<BR> This is superscript: " + sText.sup()) document.write("<BR> This is lowercase: " + sText.toLowerCase()) document.write("<BR> This is uppercase: " + sText.toUpperCase()) //--> </SCRIPT>
Previous Example-|-Next Example-|-Return to Chapter Listing