How to set the focus on a javascript modal window? -


our website involves javascript produces overlay modal windows.

there 1 accessibility problem though, once modal triggered, focus still on trigger element , not on modal itself.

these modals can include sorts of html elements, headings, paragraphs , form controls. focus begin on first element within modal, h4 tag.

i have explored using focus() function not work number of html elements.

one thought add empty a tag in window gain focus, unsure method.

very late party, existing answers not respect accessibility.

the w3c wiki page on accessible modals offers more insight what's asked in op, relevant part having tabindex=-1 on modal container (which should have aria-dialog attribute) can :focus.

this accessible way of setting focus on modal, there more documentation keeping in modal - , returning element triggered modal - quite lot explained here, suggest interested check link above.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -