John Dyer

Technology and web development in curly bracket languages {Javascript, C#, ActionScript}

Totally Unobtrusive (and totally awesome) Upside Down Text

by John Dyer 11. April 2008 02:38

There is a huge need for upside down text on the web. With everyone "going mobile," developers cannot simply rely on users having their screens oriented the same way all the time. I went through all of the possible options for creating upside down text and finally came up with a totally unobtrusive, Unicode enabled, completely web-changing piece of code (which is mostly from someone else and using this and this).

Options for Upside Down Text

  1. Images - The most obvious option for upside down text is to open up Photoshop, enter some text, and use Rotate Canvas.
    Pros: easy to do.
    Cons: must be done for every piece of text. Not every OS/browser in the world can display images. This is just unacceptable.

  2. sIFR - I know it's a little 2005 of me to say it, but a great use of Flash is to replace text and rotate it around.
    Pros: works for any HTML text element.
    Cons: requires Flash which has even less support than images. Also, requires extra coding.

  3. Canvas - one day it might be possible to do more with text drawing on a canvas tag, but right now its not
    Pros: none, for now.
    Cons: doesn't exist.

  4. JavaScript - Everyone knows JavaScript can do anything. See my experiments in 3D and color and this guy's port of Mario. Using this great script its possible to simulate upside down characters using Unicode equivalents.
    Pros: is awesome.
    Cons: nothing at all.

Usage &Implementation

Just give your HTML element a class called "upsidedowntext" and add the script in the header and you have pure greatness:

<script type="text/javascript" src="upsidedown.js"></script>

<div class="upsidedowntext">I can be read in any orientation</div>
<div>I can be read in any orientation</div> <div class="upsidedowntext">This is Tom Cruise taking your picture</div> <div>This is a boring Russian Mig</div>

Result:

uoıʇɐʇuǝıɹo ʎuɐ uı pɐǝɹ ǝq uɐɔ ı
I can be read in any orientation

ǝɹnʇɔıd ɹnoʎ ƃuıʞɐʇ ǝsınɹɔ ɯoʇ sı sıɥʇ
This is a boring Russian Mig

Demo and Download


Note: this post was intended to be an light-hearted (late) April's fools poke at all the random stuff developers are doing with JavaScript, sometimes in the name of a standard or idea that really isn't really needed. Also, I think upside down text is funny.

Comments

4/11/2008 4:01:41 AM # AP AP United States | Reply
Sweet illustration using Maverick and the Russian Mig. I can already think of hundreds of uses for this javascript, mostly in combination with a random number generator (standards compliant of course) and next April Fools Day.
4/11/2008 8:00:48 PM # Evan Mullins Evan Mullins United States | Reply
That's really interesting. So looking at the script you're mapping the characters to 'upsidedown' equivalents... Pretty slick.
I like how it gives it that 'ransom note' look.
Evan Mullins's last post: blog.circlecube.com/.../" rel="nofollow">Better jquery mega-menu tutorial
4/11/2008 10:48:03 PM # Arthur Lawry Arthur Lawry United States | Reply
Looks a little off in firefox (upside down replacements look to be of a larger font size).  I surrounded each of the special characters with spans with a font size of .83em and it fixed it in Firefox 2.0

I also had trouble in IE as all special characters were by default rendered as rectangular boxes.

Either way, really unusual and whimsical use of javascript Smile
7/27/2008 9:06:07 AM # Alexander Higgins Alexander Higgins United States | Reply
Ok, that's a neat little trick, but I thought Javascript did not work in rss feeds?? Looking at your feed, the text is upside down there as well.
Alexander Higgins's last post: blog.alexanderhiggins.com/.../" rel="nofollow">BP Gulf Oil Spill Fishing Waters Opened East Of Mississippi River Despite Oil Just A Few Miles Away
3/6/2009 7:00:25 AM # ☆.•°❤LiL' MiSs CuLLeN❤°•.☆ ☆.•°❤LiL' MiSs CuLLeN❤°•.☆ United States | Reply
y wont diss work?
3/21/2009 5:18:32 PM # trackback vincent_赵 | Reply
《转》--超赞的JavaScript效果展示

转至博客园JavaScript小组
3/24/2009 4:58:28 PM # Lucas Lucas Spain | Reply
Nice..
it would be even nicer if we can have only the V flip without having an H flip.. it would look like mirror effect. If topcase letter works fine in V flip ofcourse..
Best regards
Lucas
7/21/2010 1:34:41 PM # Venkat Koduru Venkat Koduru United States | Reply
The Javascript option does have quite a few cons.  First not all browsers can display the unicode upside down characters. Look at this page here http://www.upsidedowntext.com/unicode on an old version of Internet Explorer. It shows the upside down mappings you are referring to. You'll notice on certain browsers a question mark or something similar will show up.  Also, though that are pretty good upside down equivalents for lowercase letters, if you look at the conversions for upper-case characters or numbers you will either notice they are non existent or no that good.

That javascript upside down text conversion is really for Facebook statuses and that sort of thing - not for a serious application.
7/22/2010 2:25:23 PM # Hair Extensions London Hair Extensions London United States | Reply
Looks really cool these javascripts really makes your sites look cooler I'm really looking for some navigation menu javascript that will make my site a lot better any suggestions?

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Web Statistics