Autofocus in search bar?
Autofocus in search bar?
Hello everyone. I am using Flare to build an HTML5 help with a side navigation skin and a search bar whithin the header. When users call up the start page, the input focus is not within the search bar, but this is now desired by the product management. The HTML codes for this can be researched, but I don't know where (stylesheet, skin, start page?) I would have to insert which code. Does anyone have any idea how and whether this feature ("autofocus on load") can be achieved in MadCap Flare?
Re: Autofocus in search bar?
You could do this using JavaScript.
For example, somewhere inside the body of the start page, insert a script using Insert > Script and paste the following:
However, it's not good practice to do this for accessibility reasons, because it breaks the normal navigation flow of your page for keyboard users. It will jump over things like the 'skip to content' link. I've actually removed this from our help after it failed accessibility tests. So I'd mention that to management!
For example, somewhere inside the body of the start page, insert a script using Insert > Script and paste the following:
Code: Select all
$(document).ready(function(){
/* Set focus to search bar in title bar automatically */
$(".title-bar .search-field").focus();
});;
Re: Autofocus in search bar?
Thanks a lot, NorthEast,
I'll definitely mention that to management!
I'll definitely mention that to management!