How to support placeholder attribute in IE8 and 9
You can use any one of these polyfills:
- https://github.com/jamesallardice/Placeholders.js (doesn't support password fields)
- https://github.com/chemerisuk/better-placeholder-polyfill
These scripts will add support for the placeholder
attribute in browsers that do not support it, and they do not require jQuery!
the $.Browser.msie is not on the latest JQuery anymore... you have to use the $.support
like below:
<script>
(function ($) {
$.support.placeholder = ('placeholder' in document.createElement('input'));
})(jQuery);
//fix for IE7 and IE8
$(function () {
if (!$.support.placeholder) {
$("[placeholder]").focus(function () {
if ($(this).val() == $(this).attr("placeholder")) $(this).val("");
}).blur(function () {
if ($(this).val() == "") $(this).val($(this).attr("placeholder"));
}).blur();
$("[placeholder]").parents("form").submit(function () {
$(this).find('[placeholder]').each(function() {
if ($(this).val() == $(this).attr("placeholder")) {
$(this).val("");
}
});
});
}
});
</script>
You could use this jQuery plugin: https://github.com/mathiasbynens/jquery-placeholder
But your link seems to be also a good solution.