What I have:
A standard log-in page (specifically, the default WordPress wp-login.php page).
Here are two live examples:
- https://twentyfourteendemo.wordpress.com/wp-login.php
- http://demo.opensourcecms.com/wordpress/wp-login.php
What I need:
I need to disable the auto-focusing of the first textbox in the form.
What I’ve tried:
- I’ve attempted a hidden or off-screen positioned textbox to steal focus.
- I’ve attempted setting the tabindex of all inputs to -1 (very unideal).
- I’ve attempted using .blur() on the auto-focused textbox.
None of the approaches work.
For those coming from Google, there is now a hook for this in the core (correct from V5.2, could be earlier!).
wp-login.php:1149 enable_login_autofocus : Boolean
Will disable the autofocus javascript snippet
I’ve posted a few solutions on the WordPress SE here. Basically there are two ways around it (in WordPress 4.0) that don’t involve changing the code itself. Kill the function altogether using a dirty hack:
Or use Geeklab’s solution to modify the HTML code through buffering, allowing you to specifically kill the autofocus. Good luck!
I’ve found a solution based on charlietfl’s setTimeout function.