一个按钮内部链接不能在Firefox工作 [英] Link inside a button not working in Firefox

查看:136
本文介绍了一个按钮内部链接不能在Firefox工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮中的两个链接,但链接似乎并不在Firefox上运行。

I have two links inside a button but the links don't seem to work on Firefox.

<button class="btn login">
    <a href="/login"><b>Log In</b></a> 
          | 
<a href="/signup"><b>Sign Up</b></a>
</button>

我试过的JavaScript的onclick和重定向 - 即使不工作

I tried JavaScript onclick and redirecting - even that is not working.

推荐答案

这不起作用,因为的它不是由HTML5允许

内容模型:段落式内容,但必须有没有互动
  内容后裔。

Content model: Phrasing content, but there must be no interactive content descendant.

<一个href=\"http://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#interactive-content\">Interactive含量是指任何以下元素的

一个音频(如果控件属性为present)按钮的详细信息嵌入
  IFRAME IMG(如果USEMAP属性是present)输入(如果该类型
  属性是不是在隐藏状态)凯基标签菜单(如果该类型
  属性是在工具条状态)对象(如果USEMAP属性是
  present)选择textarea的视频(如果控件属性为present)

a audio (if the controls attribute is present) button details embed iframe img (if the usemap attribute is present) input (if the type attribute is not in the hidden state) keygen label menu (if the type attribute is in the toolbar state) object (if the usemap attribute is present) select textarea video (if the controls attribute is present)

如果它确实在某些浏览器工作,这只是因为他们正试图
发挥好与畸形的标记和提供的部分之类的有意义的结果。

If it does work in some browsers it's just because they're trying to play nice with malformed markup and provide some sort of meaningful result.

在换句话说:重写你的HTML,它是一个烂摊子。如果你想要的链接,看起来他们是在一个按钮,将它们放在一个 DIV 元素和风格,看起来像之一,而不是滥用它语义错误的元素

In other words: rewrite your HTML, it's a mess. If you want the links to look like they're in a button, put them in a div element and style that to look like one, instead of abusing semantically wrong elements for it.

这篇关于一个按钮内部链接不能在Firefox工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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