Drop-in jQuery placeholder fix

If you want to enable the “placeholder” attribute of input boxes in browsers that don’t support it, simply download this file, and include it anywhere on your page. It will copy the native functionality, and disable itself in browsers that already support the attribute.

This file will require a reasonably new version of jQuery to run correctly (and yes, it works in no-conflict mode).

jQuery.placeholder.1.0.1.min

Comments, questions? Feel free to comment.

NOTE: This project has been moved into github

Get latitude and longitude of an address using google maps

Google doesn’t make it easy to show you the latitude and longitude of an address you search in google maps, but there’s an easy way to get the info.

  1. go to google maps, type the address, and click search
  2. once you’ve found it, go to your address bar and clear what’s in it
  3. paste: javascript:void(prompt('',gApplication.getMap().getCenter())); into the address bar
  4. use the coordinates for whatever you wish!

Embedding Web Fonts: A cautionary tale

So for work, the designer says “Hey, can we use this font in the webpage” and like an idiot, I say “sure, why not?”. Well, FF and Safari don’t support .otf files (for whatever reason) So I download FontForge, open it in X11 (on my mac) and convert it to .ttf, which works great.

Then I messed around in IE, trying to make it work, even downloading this tool:

Microsoft WEFT

Worst thing EVER. Don’t do this. Don’t get this. Don’t even look at this. You will feel violated if you use it.

So…how to embed an OTF font in a website (make sure you have a license to do so kids):

  1. Convert OTF file to .ttf (use fontForge)
  2. Embed with @font-face
  3. When adding the font to a style, in IE you CAN NOT call it by the name you gave it with the @font-face declaration. You have to call it by it’s name. So if the font’s name is myfontLTSTDBOLDITALICROMAN you have to do: body{ font-family: myfontLTSTDBOLDITALICROMAN; } Sucky? Very. Works? yes.

Have a nice day

Cause a field to be auto-focused when the page is done loading

So, wouldn’t it be user friendly, if when you went to a form page in a document, if the cursor was automagically positioned at the first field in the form?

Why, yes it would. Try:

	
Event.observe(window, 'load', function(){
     try {
          $('eventName').focus();
     } 

     catch (e) {}
});

after your </form> tag. This requires the prototype javascript library