【问题标题】:during accessibility testing, tools complain that my google search box is missing a title在可访问性测试期间,工具抱怨我的谷歌搜索框缺少标题
【发布时间】:2018-07-26 21:53:36
【问题描述】:

我的谷歌搜索框代码

(function() {
var cx = 'x';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript'; 
    gcse.async = true;
    gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
  window.onload = function(){
    document.getElementById('gsc-i-id1').placeholder ='Search This Website'; 
    document.getElementById('gsc-i-id1').alt = 'website search';
 }

Waves 工具警告是“带有标题的未标记表单元素”。我怎样才能摆脱这个警告?

【问题讨论】:

    标签: html wcag2.0


    【解决方案1】:

    alt 仅对<input type="image"> 有效。如果你使用aria-label="website search",应该会很满意。

    【讨论】:

    • 当我尝试这样做时,我的整个搜索栏都消失了。
    • 添加 ARIA 标签会使内容消失?我对此表示怀疑。
    • 好的,也许 aria-label 不是 gsc-i-id1 google bar 的属性?你会在哪里添加 aria-label,在按钮元素上?我也试过了,错误仍然存​​在。你说 alt 是用于 gsc-i-id1 元素确实具有的图像类型。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-01
    • 2015-10-31
    • 2018-06-25
    • 1970-01-01
    • 2013-10-25
    相关资源
    最近更新 更多