CSS 按钮在 IE 中不起作用,但在 FF 中起作用
我一直在互联网上寻找解决方案,解释为什么 IE7 不能正确打开链接,例如
<a href="http://www.google.com"><button class="class1">Google</button></a>
IE7 不喜欢有吗?
我听说我应该使用 jquery 来实现这个?但没有人链接到任何文章。
I've been looking on the internet for solutions as to why IE7 isn't opening links correctly for example
<a href="http://www.google.com"><button class="class1">Google</button></a>
Does IE7 not like having ?
I hear I should use jquery for this? But no one linked to any article.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
根据 W3C 的规范 anchor (< code>) 标签 和
<按钮>
标签,你应该能够做到这一点,但是根据快速 Google 搜索,您不能和/或不应该这样做,而且它在 Internet Explorer 中不起作用。这篇文章实际上推荐添加Javascript,这样链接也可以在IE中打开:
According to the W3C's specifications on anchor (
<a>
) tags and<button>
tags, you should be able to do that fine, but according to a quick Google search, you can't and/or shouldn't do it, and it doesn't work in Internet Explorer.This article actually recommends adding Javascript, so the link can be opened in IE also:
尽管可以,但锚点 (
) 内不应有按钮 (
向按钮添加一个事件处理程序,如下所示:
注意:出于多种原因,您应该考虑不这样做。最重要的是,您可以(并且应该)将
元素设置为看起来像按钮。
Although you can, you shouldn't have a button (
<button>
) inside anchor (<a>
).Add an event handler to the button like this:
Note: you should considered not doing this, for a variety of reasons. Bottom line you can (and should) style your
<a>
element to look like a button.最好不要使用超链接内的按钮。
将超链接设置为看起来像按钮。
尝试这些
http://www.webresourcesdepot.com/css3-buttons-10-awesome-ready-to-use-solutions-all-lated-tutorials-you-need/
You're better off not using a button inside a hyperlink.
Style the hyperlink to look like a button.
Try these
http://www.webresourcesdepot.com/css3-buttons-10-awesome-ready-to-use-solutions-all-related-tutorials-you-need/
试试这个:
或者干脆删除按钮标签并使用这个:
Try this:
Or simply remove the button tag and use this:
为了独立于 JavaScript(这样它也可以在禁用 JS 的浏览器上工作,与这里的许多其他答案相反),我建议将其以通常的方式包装在
或者
To be JavaScript independent (so that it also works on browsers with JS disabled, in contrary to many other answers here), I'd suggest to just wrap it in a
<form>
the usual way and make it a<button type="submit">
(or<input type="submit">
) instead.or