JavaScript using String, JavaScript Tutorial, Global Guide Line Technology.
Bookmark Bookmark: JavaScript using String, JavaScript Tutorial Forum | Blog |

      Home                    

Basic JavaScript Guide.
 JScript Introduction.            
 JScript Why?                       
 JScript Recognitions.          
 JScript onMouseover.         
 JScript with Buttons.           
 JScript Alerts.                     
 JScript Variables.               
 JScript Operators.               
 JScript Functions.               
 JScript Prompts.                 
 JScript Conditions.             
 JScript Validations.            
 JScript Confirmation Boxes.
 JScript Browser Detection.  
 JScript Redirection.            
 JScript on Links.                 
 JScript Switch.                    
 JScript Loops.                     
 JScript Events.                    
 JScript Exception Handling.
 JScript Reserve Characters. 
 JScript with Objects.            
 JScript Math Object.           
 JScript using Dates.             
 JScript using String.
 JScript using Arrays.            
 JScript Operations.              
 JScript Handling Cookies.   
 JScript in Mapping.             
 JScript Time Out.                
 JScript Summary.                

JavaScript Tutorial >> JavaScript using String.


     Back             Next     


To help format text programmatically, JavaScript exposes several default JavaScript String methods and a single property for which the JavaScript String object commands, and all of which any text-containing JavaScript variable can directly access. The below example shoes how to set-up text string using JavaScript.

Example of String Methods in JavaScript

<script language="javascript">
  var myString="Welcome at Global Guide Line! JavaScript Tutorial"
  var format=myString.toUpperCase()
  var size=1
  //go through the myString, letter by letter with JavaScript for loop
  for (i=0;i<myString.length;i++){
    document.write(format.charAt(i).fontsize(size).bold())
    if (size<7){
      size++
    }
    else{
      size=1
    }
  }
</script>

Result for above Example of JavaScript with String Object.


String Object Formatting related properties & methods in JavaScript

JavaScript String Property Names Description of JavaScript String Property
length Length property of JavaScript String Object returns the total number of characters of any string.
JavaScript String Methods Names Description of JavaScript String Methods
anchor(name) anchore() Method of JavaScript String returns the string with the tag <A name="name"> surrounding it.
big() big() Method of JavaScript String returns the string with the tag <BIG> surrounding it.
blink() blink() Method of JavaScript String returns the string with the tag <BLINK> surrounding it.
bold() bold() Method of JavaScript String returns the string with the tag <B> surrounding it.
fixed() fixed() Method of JavaScript String returns the string with the tag <TT> surrounding it.
fontcolor(color) fontcolor() Method of JavaScript String returns the string with the tag <FONT color="color"> surrounding it. .
fontsize(size) fontsize() Method of JavaScript String returns the string with the tag <FONT size="size"> surrounding it.
italics() italics() Method of JavaScript String returns the string with the tag <I> surrounding it.
link(url) link() Method of JavaScript String returns the string with the tag <A href="url"> surrounding it.
small() small() Method of JavaScript String returns the string with the tag <SMALL> surrounding it.
strike() strike() Method of JavaScript String returns the string with the tag <STRIKE> surrounding it.
sub() sub() Method of JavaScript String returns the string with the tag <SUB> surrounding it.
sup() sup() Method of JavaScript String returns the string with the tag <SUP> surrounding it.
toLowerCase() toLowerCase() Method of JavaScript String returns the string with all of its characters converted to lowercase.
toUpperCase() toUpperCase() Method of JavaScript String returns the string with all of its characters converted to uppercase.
 

Concatenate different JavaScript  Strings.

<script type="text/javascript">

var arr = new Array(3)
arr[0] = "Global"
arr[1] = "Guide"
arr[2] = "Line"
arr[3] = " >> "
arr[4] = "JavaScript"
arr[5] = "Tutorial"


document.write(arr.join(" ") + "<br/>")
document.write(arr.join() + "<br />")
document.write(arr.join(".") + "<br/>")

</script>
 

Out put of concatenate different JavaScript Strings example


Example of String Complete Functions in JavaScript

<script type="text/javascript">
  var string="JavaScript String Functions Example in JavaScript Tutorial!"

  document.write("<p>Big: " + string.big() + "</p>")
  document.write("<p>Small: " + string.small() + "</p>")

  document.write("<p>Bold: " + string.bold() + "</p>")
  document.write("<p>Italic: " + string.italics() + "</p>")

  document.write("<p>Blink: " + string.blink() + " (does not work in IE)</p>")
  document.write("<p>Fixed: " + string.fixed() + "</p>")
  document.write("<p>Strike: " + string.strike() + "</p>")

  document.write("<p>Fontcolor: " + string.fontcolor("Red") + "</p>")
  document.write("<p>Fontsize: " + string.fontsize(16) + "</p>")

  document.write("<p>Lowercase: " + string.toLowerCase() + "</p>")
  document.write("<p>Uppercase: " + string.toUpperCase() + "</p>")

  document.write("<p>Subscript: " + string.sub() + "</p>")
  document.write("<p>Superscript: " + string.sup() + "</p>")
  document.write("<p>Its Link: " + string.link("https://www.GlobalGuideLine.com") + "</p>")

</script>

Out put of all JavaScript String Functions.



     Back             Next     
 

JavaScript String Object Functions and Properties Examples



[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2018 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 201 visitors are online now