JavaScript : String Objects

Posted by ActiveEnnovations

JavaScript treats Strings as objects, and therefore there is a respective String Object Class that contains functions for manipulating the strings. This can make JavaScript very handy for manipulating the text without having to write all of the text formatting in html code.

 

<html>

<body>

<script type="text/javascript">

var line="I am a line of text";

document.write("Original lineence: "+line);

document.write("<br />");

document.write("blink, works in FF not IE "+line.fontcolor("orange").blink());

document.write("<br />");

document.write("toLowerCase() "+line.fontcolor("green").toLowerCase());

document.write("<br />");

document.write("toUpperCase() "+line.fontcolor("red").toUpperCase());

document.write("<br />");

document.write("toLowerCase() "+line.fontcolor("green").toLowerCase());

document.write("<br />");

document.write("big() "+line.big());

document.write("<br />");

document.write("small() "+line.fontcolor("red").small());

document.write("<br />");

document.write("bold() "+line.bold());

document.write("<br />");

document.write("italics() "+line.fontcolor("green").italics());

document.write("<br />");

document.write("fixed() "+line.fontcolor("brown").fixed());

document.write("<br />");

document.write("fontsize(5) "+line.fontcolor("green").fontsize(5));

document.write("<br />");

document.write('indexOf("h") '+line.fontcolor("green").indexOf("h"));

document.write("<br />");

document.write('lastIndexOf("l") '+line.fontcolor("green").lastIndexOf("l"));

document.write("<br />");

document.write("Superscript--sup() "+line.fontcolor("green").sup());

document.write("<br />");

document.write("Subscript--sub() "+line.fontcolor("green").sub());

document.write("<br />");

document.write("strike() "+line.fontcolor("red").strike());

var linked="Bertini Shoes";

document.write("<br />");

document.write("link() "+linked.fontcolor("green").link("http://www.bertini-shoes.com"));

</script>

 

</body>

</html>

This will produce the following output:

Posted on: 7/29/2010 at 10:31 PM
Tags: , ,
Categories: JavaScript
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (14) | Post RSSRSS comment feed

Comments

hemroid treatment United States

Tuesday, September 28, 2010 3:45 PM

hemroid treatment

Awsome article! I was curious if you want guest posters on your site? I would like to write something because I have done a lot of work in this area. Email me and let me know. Thanks!

Joana Sidorowicz United States

Monday, October 18, 2010 1:45 PM

Joana Sidorowicz

Why even bother?

Harvey Mixdorf United States

Thursday, October 21, 2010 1:47 AM

Harvey Mixdorf

I read your blog all the time and I just thought I’d say keep up the good work!

Titus Obyrne United States

Thursday, October 21, 2010 3:47 AM

Titus Obyrne

I enjoy checking in daily to see your writings.  I have your page bookmarked on my must read list!

Carmelita Glomb United States

Thursday, October 21, 2010 8:40 AM

Carmelita Glomb

Hey can I use some of the insight found in this entry if I provide a link back to your site?

where to watch hd movies online United States

Friday, October 22, 2010 5:42 PM

where to watch hd movies online

I was thinking regarding this just this evening.... and voila, I'm reading about it right now on your blog. Coincidence or what?

sauny United States

Saturday, October 23, 2010 9:02 AM

sauny

That is some inspirational stuff. Never knew that opinions could be this varied. Thanks for all the enthusiasm to offer such helpful information here.

Stan Meling United States

Saturday, October 23, 2010 11:51 AM

Stan Meling

Hello can I use some of the material found in this entry if I reference you with a link back to your site?

Fawn Grabo United States

Saturday, October 23, 2010 7:17 PM

Fawn Grabo

Hello may I quote some of the content found in this blog if I link back to you?

Bessie Davey United States

Monday, October 25, 2010 1:12 PM

Bessie Davey

Outstanding post. Only just discovered it on Aol. Many thanks for that helpful information. Continue to keep up the superb hard work Smile

acai weight loss United States

Tuesday, October 26, 2010 3:15 PM

acai weight loss

Just discovered this blog thru Google, what a way to brighten up my week!

stay at home mom jobs United Kingdom

Wednesday, October 27, 2010 12:56 AM

stay at home mom jobs

This blog site has got some very useful info on it. Thanks for informing me!

Nokia Mobile Phone Insurance United Kingdom

Monday, November 22, 2010 8:11 PM

Nokia Mobile Phone Insurance

Brilliant, thank you, I will visit again now.

Gadget Insurance United States

Monday, November 22, 2010 8:15 PM

Gadget Insurance

Could you message me with some hints on how you made this blog site look this cool, I'd appreciate it.

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading