我正在开发一个符合WCAG的网站,我们实现了链接,导航到一个新的标签,通过遵循WCAG网站上建议的模式。
下面是一个例子:(谷歌和IE)
http://www.w3.org/wai/wcag20/techniques/working-examples/g201/new-window.html
如果将鼠标悬停在该链接上,然后单击,则会出现“新建”选项卡。当您在原始选项卡上单击“上一步”时,悬停将保持打开状态,直到您单击某个地方。
我不确定这是一个bug还是设计的,但是什么是一个合适的WCAG方法来清除它。使用Javascript可能会起作用,但我不熟悉如何使用钩子。
我想在悬停上做一个过渡,过了x秒,它就消失了。这对WCAG的遵守是好的吗?
<?xml version="1.0" encoding="utf-8"?>
<!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>
<title>Pop-Up Warning</title>
<style type="text/css">
body
{
margin-left:2em;
margin-right:2em;
}
:focus
{
outline: 0;
}
a.info
{
position:relative;
z-index:24;
background-color:#ccc;
color:#000;
text-decoration:none
}
a.info:hover, a.info:focus, a.info:active
{
z-index:25;
background-color:#ff0
}
a.info span
{
position: absolute;
left: -9000px;
width: 0;
overflow: hidden;
}
a.info:hover span, a.info:focus span, a.info:active span
{
display:block;
position:absolute;
top:1em; left:1em; width:12em;
border:1px solid #0cf;
background-color:#cff;
color:#000;
text-align: center
}
div.example
{
margin-left: 5em;
}
</style>
</head>
<body>
<h1>Pop-Up Warning</h1>
<p>
This is an example of an <a target="_blank" class="info" href="http://example.com/popup_advisory_technique.html"><strong>External link</strong><span>Opens a new window</span></a>
</p>
</body>
</html>
根据注释,target=“_blank”
属性将在新的选项卡中打开页面,并保持当前选项卡中的状态不变。您可以删除target=“_blank”
,并在当前选项卡中打开页面。也可以使用javascript清除单击回调中的焦点状态
<a target="_blank" onclick="this.blur();">Hello<span>Open in new window</span></a>