IE表单动作网址问题 [英] IE form action URL issue
问题描述
我的表单网址类似于 https://x.com/formurl/dynamicvalue
和我的表单元素是
< form action =method ='post'> ;
...
< / form>
一些值 除IE以外的其他浏览器将动作发送到 IE表单行动发送到 我不知道为什么会发生这种情况,我可以替换document.URL来发布表单以解决问题。不过,我想要什么原因让IE删除 我正在测试IE-9 请别人教我。 预先致谢。 在使用 dynamicvalue
设置为空字符串。
$ b
li> plan2
https://x.com/formurl/dynamicvalue
https://x.com/formurl
dynamicvalue
动作
属性时,我也发现了Internet Explorer 11中的这个错误> action
< form action =method =post>< / form>
如果在javascript中读取form.action属性并且当前URL不包含尾部斜线,网址的最后部分将被删除。也就是说,如果位置 example.com/xxx/yyy
, form.action ==example.com/xxx
,而如果位置 example.com/xxx/yyy/
, form.action ==example.com/xxx/yyy/
。然而,如果表单是通过点击提交按钮发布的,它会发布到正确的URL,即 example.com/xxx/ yyy
或 example.com/xxx/yyy/
。
我克服了这个使用jQuery的 attr
函数检查HTML中的 action =
,然后使用
$ p $ < =='')return location.href else return $(form).attr('action')
(为什么有人会这样做?我拦截表单提交并使用ajax发送数据。为此,我需要知道表单要提交的位置)
Recently i am started tuning our products to IE compatability. Now i am facing a weird problem in IE alone.
My form url is something like this https://x.com/formurl/dynamicvalue
and my form element is
<form action="" method='post'>
...
</form>
some values the dynamicvalue
holds are ( Alphanumeric characters )
- plan
- plan2
- 1234443
- 544
Except IE every other browsers sending the actions to https://x.com/formurl/dynamicvalue
IE form action is sending to https://x.com/formurl
I don't know why this is happening, I can replace the document.URL to post the Form back to solve the problem. Still, i want to what's the reason for IE to remove that dynamicvalue
I am testing in IE-9
Kindly someone teach me.
Thanks in advance.
I have also discovered this bug in Internet Explorer 11 when reading the action
attribute of a form with action
set to the empty string.
<form action="" method="post"></form>
If one reads the form.action attribute in javascript and the current URL does not contain a trailing slash, the last part of the URL will be removed. I.e., if the location is example.com/xxx/yyy
, form.action=="example.com/xxx
, while if location is example.com/xxx/yyy/
, form.action=="example.com/xxx/yyy/
.
However, if the form is posted by clicking a submit button, it is posted to the correct URL, i.e., example.com/xxx/yyy
or example.com/xxx/yyy/
.
I overcame this by using jQuery's attr
function to check if action=""
in the HTML and then I use location.href
instead.
if($(form).attr('action') === '') return location.href else return $(form).attr('action')
(Why would someone do this? I am intercepting the form submit and using ajax to send the data. To do this, I need to know where the form wants to submit)
这篇关于IE表单动作网址问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!