问题
My understanding is that when using -moz-user-focus: ignore
(see doc) on an element, Firefox should skip that element when tabbing. However, try:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<form action="/">
<input type="text" value="First">
<input type="text" value="Second" style="-moz-user-focus: ignore">
<input type="text" value="Third">
</form>
</body>
</html>
- Hit tab a first time: you're on the first text field.
- Hit tab a second time: you're on the second text field, despite the
-moz-user-focus: ignore
. Am I missing something here?
回答1:
It seems there is a bug covering this in the Mozilla bug base. Until this bug is fixed, we can use tabindex="-1"
instead of CSS as a workaround.
来源:https://stackoverflow.com/questions/3671169/how-to-get-moz-user-focus-ignore-to-work