Why doesn't focus() select my container div?

Viewed 41402

I have an index.html which has JavaScript:

byId("p").value = page;
byId("nav_container").focus();
document.forms["nav_form_main"].submit();

The focus part doesn't work here.

I want the browser to focus on a specific part of the page (almost at top).

I have tried putting the focus after the submit(), same issue there.

5 Answers

Maybe you have devtools open. I just came across this and when I closed devtools everything worked fine.

Related