placeMe.js – A Placeholder Polyfill

One of my favorite new attributes in the HTML5 Spec is the placeholder attribute. This new attribute allows us to easily add placeholder text to our input fields. When the input field is focused upon, the placeholder text is removed.

<input type="text" placeholder="Please enter your name">

This has been a standard feature on the web for quite sometime, usually being accomplished with JavaScript. With the introduction of the placeholder attribute, the browser takes care of the job for us.

Of course not every browser supports the placeholder attribute. While most modern browsers do (Firefox 4+, Chrome 4+, Safari 4+, Opera 11.6+), Internet Explorer does not.

I wanted to use the placeholder attribute without fear so I wrote a little polyfill using jQuery. I’ve decided to call it placeMe.js and give it away to anyone who would like to use it and/or improve upon it.

How to Use

First include jQuery

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

Next include placeMe.js

<script type="text/javascript" src="/path/to/placeMe-0.1.js"></script>

Now use the placeholder attribute to your heart’s content

<input type="text" placeholder="This is my awesome placeholder">

Download

Download | Demo

 

This is my first attempt at writing a polyfill, so be sure to let me know what you think in the comments.

Share in top social networks!
Posted in HTML5, IE, Polyfills at May 2nd, 2012. 1 Comment.

The Ultimate List of IE6 Fixes & Hacks

August 27, 2001. For web developers, that is a date that will live in infamy. On that unassuming August day, Internet Explorer 6 was officially released. No one could have foreseen the headaches IE6 would cause for developers. Who could have known that in late 2009 Internet Explorer 6 would still have 12.1% market share, forcing us to make sure our sites play nice with it. There have been many attempts to bring down our foe (here’s one, here’s another), but alas, IE6 won’t go down quietly.

IE6′s problems are well documented, but luckily for us a lot of smart people have found ways fix (or side step) those problems. Here is a huge list of hacks, fixes, and resources to make IE6 a little less painful.

IE6 Box Model Bug

More than likely if you’ve heard of only one IE6 bug, the box model bug is the one. In short, IE6 incorrectly calculates the width of a given box causing all sorts of layout problems. Here are some ways around this annoying bug.

Read More…

Share in top social networks!
Posted in CSS at September 1st, 2011. 1 Comment.