Source Code for a Sample Page That Formats a String Object with the 'a' Tag : String « Language Basics « JavaScript DHTML

Source Code for a Sample Page That Formats a String Object with the 'a' Tag

  <title>String Object Hypertext Formatting</title>
  <script language="JavaScript1.1" type="text/javascript">
    function showWindow(){
      var txt = document.form1.stringField.value
      if (document.form1.hypertext[0].checked){
        txt =;
        if (document.form1.hypertext[1].checked){
          txt = txt.anchor(document.form1.jumptoField.value);
    String Object Hypertext Formatting
  <form method="POST" name="form1">
      <input type=text size=20 maxlength=256 name="stringField">
      <input type=radio name="hypertext" value="Link" checked>
      <input type=radio name="hypertext" value="Anchor">
      Jump To:
      <input type=text size=20 maxlength=256 name="jumptoField">    </p>
    <input type="button" name="Show" value="Show" onClick="showWindow()">


Related examples in the same category

1.Demo all String methods
2.String utility: word count, replace and capitalize
3.Strip Commas
4.Text Range Search and Replace (IE only)
5.Counting the Words in a Text String
6.Reversing a String
7.Trimming a String Using Regular Expressions
8.String encode and decode
9.Capitalizing the First Letter in Each Word of a String
10.Playing with Strings
11. Using the String Object's Link Method
12.Using a for Loop to Reverse a String
13. Concatenate JavaScript String
14.String length: number of characters in a string.
15.String fontcolor(): a string in a specified color
16.String indexOf(): string position
17.String Validation
18.Using Quotes within Strings
19.Using the String Object
20.String toUpperCase
21.Lab for string.replace() and
22.Slicing a String
23.A String Object Prototype
24.Creating a Custom toString() Method
25.Reading a Portion of a String
26.Source Code for Our String-Formatting Script
27.Adding a replace() Method to the String Object
28.Creating a Function That Will Search and Replace in Strings
29. Using the indexOf() Method to Find All Occurrences of the Letter e in a Sentence
30.Methods and Properties of the String Object
31.String match(): returns the text if found
32.String substr() and substring(): returns a specified part of a string
33.String toLowerCase() and toUpperCase(): converts a string to lowercase and uppercase
34.Converting Strings to Upper Case
35.String encoder
36.Concatenate two string variables together
37.Search string value in an array