IE7默认形式的方法是:QUOT; GET&QUOT ;.我怎么能知道它是用户输入或默认? [英] IE7 default form method is "GET". How can I tell if it's user-entered or default?

查看:159
本文介绍了IE7默认形式的方法是:QUOT; GET&QUOT ;.我怎么能知道它是用户输入或默认?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户没有method属性创建一个窗体,好像大多数的浏览器将在表单提交的时间处理这个问题。因此,在表单元素后DOM准备好检查,你可以看到有没有法ATTR表单元素的对象。

If a user creates a form without a method attribute, it seems like most browsers will handle this at the time of form submission. So upon inspection of the form element after the DOM is ready, you can see that there is no "method" attr of the form element object.

IE7,不过,显然设置的GET一切形式的没有方法值默认值的方法。我不想争论GET或POST是否是最明智的默认,我只是想找到一种方法,使POST在所有浏览器的默认形式的方法。

IE7, however, apparently sets a default method value of "GET" on all forms without a method value. I don't want to argue about whether GET or POST is the most sensible default, I just want to find a way to make POST the default form method across all browsers.

我的问题是,如果用户的形式方法进入了GET值,或者如果IE注入该值作为默认的我不能告诉。如果存在的形式是没有方法的属性,很明显,用户没有指定一个,这样我就可以安全地默认为POST。但是,如果我看到一个表单方法的GET价值,我不能,如果用户指定,如果有人离开了黑色和IE7设置GET时在解析HTML诉说,或

My problem is that I can't tell if the user entered a "GET" value for a form method, or if IE injected that value as default. If there is no method attribute of the form, it is obvious that the users didn't specify one, so I can safely default it to POST. But if I see a GET value for a form method, I can't tell if the user specified that, or if it was left black and IE7 set GET when it parsed the HTML.

任何人有什么想法?

推荐答案

IE浏览器的行为的正确的(*)根据DTD:

IE's behaviour is correct!(*) According to DTD:

method      (GET|POST)     GET       -- HTTP method used to submit the form--

或者,在XHTML的DTD:

or, in the XHTML DTD:

method      (get|post)     "get"

这意味着,如果省略了属性,不仅形式提交因为默认情况下得到的,但DOM实际上应该包含一个的Attr 节点通过DTD默认值 GET

that means if the method attribute is omitted, not only does the form submit as GET by default, but the DOM actually should contain an Attr node for method with the DTD defaulted value GET.

(*:嗯,有点IE使用XHTML的HTML文档中的小写默认情况下,它应该是大写不是它真正重要的属性是不区分大小写的HTML反正和。哎!这是IE浏览器获取标准更正确的比所有其他浏览器。这是一个奇迹!)

(*: well, sort of. IE is using the XHTML lower-case default in an HTML document where it should be the upper-case. Not that it really matters as the attribute is case-insensitive in HTML anyhow. And hey! It's IE getting the standard more-right than all the other browsers. It's a miracle!)

所以,你怎么告诉大家,的Attr 节点,被提,因为DTD的属性存在违约,而不是因为它是在源?随着DOM 1级核心指定标志

So how do you tell that the Attr node was put there because of DTD attribute defaulting and not because it was in the source? With the DOM Level 1 Core specified flag:

var form= document.getElementById('myform');
var attr= form.getAttributeNode('method');
var isomitted= attr===null || !attr.specified;

这篇关于IE7默认形式的方法是:QUOT; GET&QUOT ;.我怎么能知道它是用户输入或默认?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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