“跳过导航”链接无法在Google Chrome中使用 [英] "Skip Navigation" link not working in Google Chrome

查看:201
本文介绍了“跳过导航”链接无法在Google Chrome中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循此页面创建跳过导航链接,但该链接无效Chrome浏览器(5.0.375.127)。

I follow this page to make a "Skip Navigation" link, however it is not working in Chrome (5.0.375.127).

当我选中并输入链接时,它会滚动到内容,但是当我继续选中时,它会从顶部开始,但不会从内容开始。

When I tab and enter the link, it scroll to the content, but when I continue to tab, it starts from the top but not start from the content.

该页面的跳过跳过导航链接在Chrome中不起作用。

That page's skip "Skip Navigation" link is not working in Chrome either.

这是Chrome的错误吗?任何解决方法?

Is it a bug of Chrome? Any workaround?

推荐答案

我明白了。目标应该是一个可以聚焦的标签,如果没有,就是我的情况一个div,应该将target的tabindex设置为-1。

I get it. The target should be a tag that can be focused, like a link, if not, which is my case a div, should set tabindex of the target as -1.

我的jQuery解决方案包含 ScrollTo插件,是:

My jQuery solution, with ScrollTo plug-in, is:

$("a[href^='#']")
    .click(function(evt){
        var j = $(evt.currentTarget);
        var anchorTarget = j.attr("href");
        $("body")
            .scrollTo(anchorTarget, 500, {
                onAfter:function() {
                    window.location.hash = anchorTarget.substr(1);
                    $(anchorTarget).attr("tabindex",-1).focus();
                }
            });

        evt.preventDefault();
    });

这篇关于“跳过导航”链接无法在Google Chrome中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆