I spent about an hour and a half digging through different JavaScripts, and I can't seem to get anything to focus the drop-down search on my website.
I've used this script to trigger the event:
<script type='text/javascript'>
function dropDownSearch(){
document.getElementById('header-dropdown-search').focus();
}
</script>
On the object: onclick="dropDownSearch()"
On the magnifier icon, I attach an onclick event to execute the script above. However, it never moves the cursor into the search field so the user doesn't have to click. I've also tried doing this by adding an event listener, but that hasn't worked either. With both scripts, I've tested with a pop-up alert. The pop-up works, but the focus doesn't. What am I doing wrong?
This is the URL to the site this is happening on: https://mypomerania.com/getting-started/
You can try with setTimeout()
function dropDownSearch() {
window.setTimeout(function () {
document.getElementById('header-dropdown-search').focus();
}, 0);
}