javascript - HTML modal popup can lose focus by tabbing to form fields in background -
i have modal popup overlay written in html / js, works fine if user tabs enough can underlying form fields / buttons. there way of preventing this?
this rough idea i'm hoping inspire ideas rather tell how it. i'll use combination of pseudocode , pseudo-jquery-code:
function showmymodaldexample() { //show modal dialog (mymodal) code goes here // //then bind event $(document).bind('mymodal.keydown', function(e) { if ( focussed element not child of mymodal ) { set focus previous element } }); }
and remember unbind mymodal.keydown when destroy/hide dialog
Comments
Post a Comment