user1701309
user1701309

Reputation: 1

Using autofocus in IE

I am a newbie in html and I m trying to set autofocus on an input text field...

But this is not supported in IE... is it possible to use JS in order to solve this problem?

Upvotes: 0

Views: 1860

Answers (3)

geekman
geekman

Reputation: 2244

<input type="text" id="aaa">
<script> 
    window.onload=function(){
        document.getElementById('aaa').focus();
    }
</script>

Upvotes: 0

Baz
Baz

Reputation: 5

Yes you can do this with javascript

e.g.

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

Where 'element' is the id of your html input.

Upvotes: 0

Matt K
Matt K

Reputation: 6709

Javascript:

document.getElementById('elemID').focus();

jQuery:

$('selector').focus();

Upvotes: 2

Related Questions