Auto Focus Form Element Javascript

For modern browsers autofocus attribute works fine with form elements, but not for older browsers. There is a Javascript to fix this problem.

HTML markup

<form>
	<input id="first" autofocus >
</form>

JavaScript

<script type="text/javascript">
   function autofocus() {
      document.getElementById('first').focus();
   }
   window.onload = autofocus;
</script>

Demo »


Go Daddy


Related articles

Vecteezy - Free Vector Art

Vecteezy - Free Vector Art

05/08/2016

If you need Free Vector Art do not hesitate: visit Vecteezy.com

Free vector icons

Free vector icons

31/01/2016

Want to have some vector icons, free? Try this nice website.

Beautiful free stock photos from StockSnap

Beautiful free stock photos from StockSnap

11/12/2015

Would you like some cool stock photos for free? Check out this article, and try this website.


Leave a comment

We welcome any comment from you! Please keep in mind that comments are moderated and rel='nofollow' is in use. So, please do not use a domain as your name or a spammy keyword, or your comment will be deleted.

Name: *

E-mail: *

Message: *

Click on the apple *


Find us on Facebook

Tags

Get online with the world's Best - GoDaddy.com!

Back to Top