当点击链接时,Firefox和IE不会失去焦点,但Chrome可以 [英] firefox and IE does not lose focus when a link is clicked, but Chrome does

查看:152
本文介绍了当点击链接时,Firefox和IE不会失去焦点,但Chrome可以的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个锚点列表,这个锚点的样式可以改变焦点和悬停的外观。点击后,他们应该恢复正常。失去焦点/变得模糊。这在谷歌浏览器中按预期工作,但在Firefox和IE浏览器没有,它保持焦点。为什么会这样?



这是我的代码: http:/ /jsfiddle.net/8fTQs/

我的猜测是,FF和IE期望页面重新加载时锚点被点击,但因为这些只是指到一个定位点(#;散列),它不会重新呈现页面(但如果它被重新加载,当然会重新渲染和失去焦点)。

做一个绕过这个?



谢谢!

编辑:我已经设置了适当的文档类型。即使页面没有被重新加载,关注点击的锚点也是正确的行为:它使得标签导航在该点之后正确地工作。

这听起来像你想要的风格:主动锚点,而不是:焦点 ones,如果你想要的样式只有当锚点被点击。


I have a list of anchors which are styled to change appearance on focus and hover. And after they are clicked they are supposed to go back to normal; lose focus/become blurred. This works as expected in Google Chrome, but in firefox and IE it doesn't, it stays in focus. Why is that so?

This is my code: http://jsfiddle.net/8fTQs/

My guess is that FF and IE expects the page to reload when an anchor is clicked, but since these are just referring to an anchorpoint (#; hash) it does not re-render the page (but if it was reloaded it would of course re-render and lose focus).

How do one go around this?

Thank you!

Edit: I have set a proper doctype.

解决方案

Focusing the anchor on click is the right behavior even if the page is not reloaded: it makes tab navigation work correctly after that point.

It sounds like you want to be styling :active anchors, not :focus ones, if you want styling only while the anchor is being clicked.

这篇关于当点击链接时,Firefox和IE不会失去焦点,但Chrome可以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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