Detect HTML5 attribute:How to implement and use autofous attribute in IE7 and IE8.

HTML5 Video tag supports on IE 8As we know the new HTML5 autofocus attribute helps  the browser to give focus to the form element. It helps to jump to the autofocused input box while our page loads.While I was checking that <input> autofocus attribute in my browser (I am using IE8) I found that IE8  is not detecting that attribute.But, I have got a solution, a tricky and way, to use and implement  autofocus attribute in IE8. Just copy the given code and save it as .html  file and check it.

<!DOCTYPE HTML>
<html>
<head>

<script type=”text/javascript” src=”http://www.ajaxblender.com/jslibs/jquery-1.4.1.js”></script>

<script type=”text/javascript”>
    $(document).ready(function(){
        //  Focus auto-focus fields
        $(‘.auto-focus:first’).focus();
     });
</script>
</head>
<body>
<form action=”demo_form.asp”>
First name:<input type=”text” name=”fname”  /><br />
Last name: <input type=”text” name=”lname”  /><br />
<input type=”submit” />
</form>
</body>
</html>

 

OUTPUT:

HTML5 Autofocus detection in IE

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: