Determine if browser allows focus on radio / checkboxes

Does anyone know if it can be determined using JavaScript if checkboxes and radio buttons can be focused in the user's browser? In other words, can you insert a tab to select them.

I can't just use browser detection to do this, because in at least one case (Safari) the user can turn this feature on and off.

Also in Safari, the focus () function is defined even when this ability is disabled, and it does not throw an error. Therefore, checking this function will not work.

0


source to share


2 answers


One approach is to try to establish focus and then determine if it was successful. Do this by assigning an onfocus event that sets the variable to true, try to focus it, and then check if the variable is true.



+1


source


JavaScript cannot read browser settings. This would be a security breach.

However, there is no way to check for something wrong if it requires interaction with the user without giving them explicit instructions to perform the checked action. So there is no passive test case for the user who has tabs disabled.



It's more like changing the screen resolution on Windows. The user changes the resolution, and since VGA is passive, the OS cannot determine if the change was successful unless the user took action. You have to ask them, set a timeout and assume that it won't work if you get a negative result. You cannot tell the difference between a negative result and a lack of user interaction.

0


source







All Articles