有什么缺点那里的<按钮和GT;标签? [英] What disadvantages are there to the <button> tag?

查看:146
本文介绍了有什么缺点那里的<按钮和GT;标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用诊断CSS样式表,例如
http://snipplr.com/view/6770/css-diagnostics--highlight-de$p$pcated-html-with-css--more/

I started using a diagnostic css stylesheet, e.g. http://snipplr.com/view/6770/css-diagnostics--highlight-deprecated-html-with-css--more/

其中的建议规则突出的类型的输入标签提交,该建议使用<按钮和GT; 为更多的语义解决方案。这是一个新的标签对我来说,做你们推荐它,还是有你已经跨越跑?缺点(如用浏览器的兼容性)

One of the suggested rules highlights input tags with the type submit, with the recommendation to use <button> as a more semantic solution. This is a new tag to me, do you guys recommend it, or are there disadvantages (such as with browser compatibility) that you have run across?

只是要清楚,我理解的规范&LT;按钮&GT; ,它有一个定义的开始和结束,它可以包含各种元素,而输入是一个单并且不能包含的东西。我想知道的本质是它是否不对头与否。因此,尽管从未使用过,我很想开始使用它,我只是不知道它是如何工作以及在现实世界中。下面的第一个答案似乎暗示它打破了用途,除了形式之外,很可惜。

Just to be clear, I understand the spec of <button>, it has a defined start and end, it can contain various elements, whereas input is a singlet and can't contain stuff. What I want to know essentially is whether it's broken or not. So despite never having used it before, I'd love to start using it, I just don't know how well it works in the real world. The first answer below does seem to imply that it is broken for uses except outside of forms, unfortunately.

修改为2015年

景观发生了变化!我有处理按钮,6年以上的经验,现在,浏览器有所来自IE6和IE7继续前行。因此,我将添加一个答案,详细说明什么,我发现了,是我的建议。

The landscape has changed! I have 6 more years experience of dealing with button now, and browsers have somewhat moved on from IE6 and IE7. So I'll add an answer that details what I found out and what I suggest.

推荐答案

从ASP.NET的角度回答。

Answering from an ASP.NET perspective.

我很兴奋,当我发现这个问题以及一些code的ModernButton控制,其中,到底,是一个&LT;按钮方式&gt; 控制

I was excited when I found this question and some code for a ModernButton control, which, in the end, is a <button> control.

于是我开始添加各种这些按钮,饰以&LT; IMG /&GT; 他们的内部标签,使他们脱颖而出。而这一切都在Firefox和Chrome伟大的工作......

So I started adding all sorts of these buttons, decorated with <img /> tags inside of them to make them stand out. And it all worked great... in Firefox, and Chrome.

然后我试图IE6,并获得被检测到有潜在危险的Request.Form值的,因为IE6提交按钮,这在我的情况下,有HTML标签在它里面的HTML。我不希望禁用validateRequest标志,因为我喜欢数据验证这一附加位。

Then I tried IE6 and got the "a potentially dangerous Request.Form value was detected", because IE6 submits the html inside of the button, which, in my case, has html tags in it. I don't want to disable the validateRequest flag, because I like this added bit of data validation.

于是我写了一些JavaScript来禁用按钮提交之前发生。在测试页伟大的工作,有一个按钮,但是当我尝试过了一个真正的页面,页面上有其他&LT上的按钮&GT; 标签,它再次炸毁。由于IE6提交所有按钮的HTML。所以现在我有各种各样的code的禁用按钮日前递交。

So then I wrote some javascript to disable that button before the submit occurred. Worked great in a test page, with one button, but when I tried it out on a real page, that had other <button> tags, it blew up again. Because IE6 submits ALL of the buttons' html. So now I have all sorts of code to disable buttons before submit.

使用IE7同样的问题。 IE8也谢天谢地这个固定的。

Same problems with IE7. IE8 thankfully has this fixed.

让人惊讶。我建议如果你正在使用ASP.NET不会沿着这条道路。

Yikes. I'd recommend not going down this road IF you are using ASP.NET.

更新:

我发现了一个图书馆,在那里,看起来很有希望解决这个问题。

I found a library out there that looks promising to fix this.

如果您使用ie8.js脚本这个库:的http:// code。 google.com/p/ie7-js/

If you use the ie8.js script from this library: http://code.google.com/p/ie7-js/

这可能工作了就好了。该IE8.js带来IE5-7加快速度与IE8的按钮标记。这使得提交的值的实际价值,只有一个按钮被提交。

It might work out just fine. The IE8.js brings IE5-7 up to speed with IE8 with the button tag. It makes the submitted value the real value and only one button gets submitted.

这篇关于有什么缺点那里的&lt;按钮和GT;标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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