本文介绍了HTML属性accesskey无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在测试所有不同的HTML标记和属性,使内容有所更新,由于某种原因,accesskey似乎无法正常工作。

So, I'm testing all different HTML tags and attributes, freshing things up a bit, and for some reason, accesskey does not appear to be working.

accesskey属性用于将键分配给元素。根据您的操作系统,按Alt +那个键(Windows)或Cmd +那个键(Mac)可以使该元素成为焦点。

The accesskey attribute is used to assign a key to an element. Depending on your OS, pressing Alt+that key (Windows) or Cmd+that key (Mac) will give focus to that element.

这里有一些东西:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
        a:focus{
            color:red
        }
    </style>
</head>
<body>
    <a accesskey="x" target="new" href="#">Hello</a>
</body>
</html>

所以我正在Windows机器上工作。因此,我希望按下Alt + x时锚点会变成红色。事实并非如此。
代码是否有问题,或者我期望发生错误的事情?

So I'm working on a Windows machine. Thusly, I expect the anchor to go red when I press Alt+x. Yet it is not.Is there something wrong with the code, or am I expecting the wrong thing to happen?

在Firefox上,什么都没有发生。 Google chrome打开一个新标签页(目标属性应为 new,这意味着在新标签页/窗口中打开),并且IE跳到锚点,但不再执行任何操作。

On Firefox, nothing happens. Google chrome opens a new tab (as it should, the target attribute say "new", which means open in new tab/window) and IE jumps to the anchor but does nothing further.

推荐答案

Firefox的accesskey修饰符是Shift + Alt。

Firefox's accesskey modifier is Shift+Alt.

这篇关于HTML属性accesskey无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 10:19