Using the JavaScript Methods for String Objects

28. November 2009 10:59

In JavaScript, Strings are their own object. As such, they have their own set of methods you can use to manipulate their attributes. This can be much faster than inserting the entire HTML markup.

 

<html>

<body>

<script type="text/javascript">

var sent="I should blink.";

document.write("Original Sentence: "+sent);

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

document.write("blink, which doesn't work in IE "+sent.fontcolor("orange").blink());

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

var lin="www.heroscapers.com";

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

document.write("link() "+lin.fontcolor("green").link("http://www.heroscapers.com"));

</script>

 

</body>

</html>

This will produce the following output:





Comments

11/29/2009 7:02:52 AM #

fat burning furnace

I was actually looking around for a blog post on this issue. The Fat Burning Furnace System by Rob Poulos is a 158 page guide on how to lose fat and gain lean muscle in order to look better and also raise your RMR (resting metabolic rate).

fat burning furnace United States |

12/22/2009 4:31:23 PM #

网页设计

thanks

网页设计 People's Republic of China |

2/20/2010 9:06:50 AM #

stock broker

Finally someone that actually knows what they are talking about - thank you!

stock broker United States |

2/20/2010 11:42:38 AM #

Daniel Millions

Great Post, I love to read articles that are informative and beneficial in nature. Thank you for sharing your experiences and I look forward to reading more.

Daniel Millions United States |

2/21/2010 3:25:57 AM #

loans for people with bad credit

In most occassions I don’t make comments on websites, but I would like to say that this post really made me to do so. Thanks!

loans for people with bad credit United States |

3/20/2010 5:42:59 AM #

watch 500 days of summer

I had to refresh the page 2 times to view this page for some reason, however, the information on here was worth the wait. I loved that it is also really easy to read for the eyes.

watch 500 days of summer United States |

3/20/2010 6:39:15 AM #

make money

Substantially, the article is really the greatest on this deserving topic. I fit in with your conclusions and will thirstily look forward to your upcoming updates. Just saying thanks will not just be sufficient, for the wonderful lucidity in your writing. I will directly grab your rss feed to stay abreast of any updates. Good work and much success in your business dealings!

make money United States |

4/15/2010 11:48:38 PM #

Man Antonio

I am impressed with all this useful information. Was WAY more than I expected. I just cannot keep up with your posts. So much information to read about.

Man Antonio United States |

4/17/2010 8:57:10 AM #

Article Directory

Articlelinker24.com is looking for new writers who are passionate about their professional careers, their small business, e-commerce, affiliate marketing or a field of scholarly study. We accept writers from diverse backgrounds who are committed helping others. Articlelinker24.com has a wide variety of subject categories to submit your article. Share your knowledge and give back to the community...post your article on Articlelinker24.com. Our article directory is free and easy to join!

Article Directory United States |

4/19/2010 3:08:17 PM #

Business Promotion

Articlelinker24.com is looking for new writers who are passionate about their professional careers, their small business, e-commerce, affiliate marketing or a field of scholarly study. We accept writers from diverse backgrounds who are committed helping others. Articlelinker24.com has a wide variety of subject categories to submit your article. Share your knowledge and give back to the community...post your article on Articlelinker24.com. Our article directory is free and easy to join!

Business Promotion United States |

4/28/2010 1:02:30 AM #

Rapidshare

I\'m happy I found this blog, I couldnt discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!

Rapidshare United States |

5/14/2010 9:59:42 AM #

free online game

hey, your site's template is awesome and loving it. Your blogposts are superb. Please keep up the good work. Greets!.

free online game United States |

5/16/2010 5:42:18 AM #

puppy housebreaking

Really a lovely post.. Thnx for discussing this stuff.

puppy housebreaking United States |

5/24/2010 7:24:31 PM #

Jaxson

Do you have a spam problem on this blog; I also use Blog Engine, and I was wondering about your situation; we have developed some excellent practices and we would like to exchange thoughts with others, please Email me if interested. If you have a premature baby, things are going to be a bit different in the early days.

Jaxson India |

Comments are closed


About the author

 The creators of the Web Design Blog have been creating web designs for over 12 years

Page List