3

在 chrome 中,我专注于“A”iframe。其他 iframe 上有元素设置 accesskey 属性。我不能使用 accesskey 来关注元素。IE、FF 不存在此问题。

有什么技巧可以解决这个问题吗?我的代码如下:

索引.html:

<!doctype html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Index</title>
</head>
<body>
    <input type="text"  accesskey="b" name="some_name" value="">
    <iframe src="a.html"></iframe>
    <iframe src="b.html"></iframe>
</body>

一个.html:

<!doctype html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Index</title>
</head>
<body>
    <input type="text"  accesskey="e" name="some_name" value="">
</body>

b.html:

<!doctype html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Index</title>
</head>
<body>
    <input type="text"  accesskey="t" name="some_name" value="">
</body>
4

1 回答 1

0

问题将与当前关注的背景有关。因此,如果用户没有在相应的 iframe 内单击,则访问密钥将不起作用。实现这一点的一种方法是触发 javascript keyevent,它将键事件转发到每个 iframe,直到它满足相应的访问键属性。

于 2016-06-24T08:24:56.670 回答