【发布时间】:2019-05-19 05:22:39
【问题描述】:
我正在创建一个客户的网站以使其易于访问。我们从带有 YouTube 视频的 iFrame 中提取视频。视频运行良好,更新了隐藏式字幕等。但是,YouTube 频道徽标上显示的 aria-label 显示为“照片图像”,不符合无障碍指南。
<a class="ytp-title-channel-logo" target="_blank" data-visual-id="2" href="https://www.youtube.com/channel/lettersandsuch" aria-label="Photo image of " style="background-image: url("https://filepathforphoto.png");"></a>
由于它在 iFrame 中,我不知道我们是否真的可以使用 JS 抓取和更改 iFrame。我尝试在 YouTube 帐户中更改徽标并更新频道名称,但它没有打到 aria-label。
我尝试使用 jQuery 更改它,但我认为我做得不对。我在 iFrame 上放了一个 id 并应用了这个:
$(document).ready(function(){
var iFrameDOM = $("iframe#frameID").contents();
iFrameDOM.find('.ytp-title-channel-logo').attr('aria-role', 'something');
})
它没有在本地显示任何错误,但没有应用代码更改。有没有办法更改 YouTube 频道徽标上的 aria-label?
【问题讨论】:
-
我试过你的代码,如果它不是跨域的,那么它会改变 aria-label 的值!
标签: jquery youtube youtube-api