Web Programming

[Resolved] Firefox getElementById(‘id’).focus() NOT WORKING

Not like other web browsers, Firefox won’t execute getElementById(‘yourid’).focus() function in your javascript code. However, you can use setTimeout function to complete the task. simply change your line of code to this:

setTimeout(“yourid.focus();”,0);

Example of Code

The old one –> Won’t working in Firefox

<script>
function kembalifokus() {
document.getElementById(‘rfid’).focus();
}
</script>

 

The Correct one –> Will works in Firefox

<script>
function kembalifokus() {
setTimeout(“rfid.focus();”,0);
}
</script>

Leave a Reply