A blog & community for non-professional web designers, programmers, webmasters, and other web savvies.

Display Text Backwards

February 28, 2011 - 12:00am -- aashni

Ever wanted to write backwards? This little script let's you. It creates a loop that displays the letters in the opposite direction.

Directions: Replace the text in msg1 with the text you want reversed. If you want anything written before or after the backwards text, place them in the before and after variables.

<script type="text/javascript"><!--
// ***************
// Display Text Backwards
// More JavaScript Scripts at
// http://icecaves.net/tags/javascript
// ***************
var msg1="This text is backwards.. how cool right?";
var before = "";
// You put the tags you want before the text here.
var after = "";
// you put the closing tags here.
var msg2="";
for (count=msg1.length; count >= 0; count--)
msg2+=msg1.substring(count,count-1);
document.write (before,msg2,after);
//-->
</script>
Code Preview: 
Forum Board: 

Comments

Chase
Chase's picture
Snowball (?)
Rank Points: 4 (?)
Age: 13
Posts: 3
Status: Offline
WWW

You can also use the strrev() function in php. :D

<?php
echo strrev("Backwards");
?>
Thomas
Thomas's picture
Glacier (?)
Elite Yeti (?)
Rank Points: 107 (?)
Age: 15
Posts: 1,160
Status: Online
WWW
Chase wrote:

You can also use the strrev() function in php. :D

<?php
echo strrev("Backwards");
?>

There is a php version of this here.

--------------------

Soccer
Soccer's picture
Snowman (?)
Rank Points: 13 (?)
Posts: 62
Status: Offline

sdrawkcab etirw tsuj i t'naC ?siht si lufesu woH

Anna
Anna's picture
Icicle (?)
Elite Yeti (?)
Rank Points: 48 (?)
Age: 17
Posts: 827
Status: Online
WWW

.troffe fo tol a dna emit gnol a sekat ti tub dluoc uoy esoppus I

--------------------

Yay, Anna!
AnnaNeo

Soccer
Soccer's picture
Snowman (?)
Rank Points: 13 (?)
Posts: 62
Status: Offline

it takes a lot of effort to remember the code :/

right now i'm too lazy to do either...

and this really has no uses.

jellsprout
jellsprout's picture
Puddle (?)
Rank Points: 1 (?)
Posts: 34
Status: Offline

@IceCaves on Twitter

    Stay Connected

    Twitter Facebook Tumblr Google+ Glaciallis Google RSS

    *Follow us on Twitter or Facebook to also follow minor site updates that don't make it to the homepage news.