I have come across a strange issue which seems to be browser related(IE9 and lower vs. IE11), but would like to know why the strange behavior.
我遇到了一个奇怪的问题,似乎是与浏览器相关(IE9和较低的IE11),但想知道为什么奇怪的行为。
Issue Description:I use a spring framework and use its related taglibs to retrieve data on my JSP. There is a variable called index which I retrieve from the form and it used to be retrieved in the following manner.
问题描述:我使用spring框架并使用其相关的taglibs来检索我的JSP上的数据。有一个名为index的变量,我从表单中检索它,它曾经用以下方式检索。
<html:hidden property="index" name="pdmAcctSuppressForm" />
Value for the above variable namely index
was accessed in a javascript using the following code snippet.
使用以下代码片段在javascript中访问上述变量(即索引)的值。
var index = document.getElementById("index").value;
The javascript seems to work as expected and retrieves the actual value in all IE browsers until IE9, but seems to fail to work on IE11. document.getElementById("index")
returns invalid on IE11.
javascript似乎按预期工作,并在IE9之前检索所有IE浏览器中的实际值,但似乎无法在IE11上工作。 document.getElementById(“index”)在IE11上返回无效。
Solution: The problem has been resolved by changing the above mentioned taglib implementation from <html:hidden property="index" name="pdmAcctSuppressForm" />
解决方案:通过从
to
<input type="hidden" name="pdmAcctSuppressForm" value="${pdmAcctSuppressForm.index}" id="index"/>
I would like to know what has been changed on IE11 which renders the implementation unusable and also if the solution I have quoted is the right and efficient one.
我想知道在IE11上有什么变化,这使得实现无法使用,而且如果我引用的解决方案是正确和有效的。
1 个解决方案
#1
The javascript seems to work as expected and retrieves the actual value in all IE browsers until IE9, but seems to fail to work on IE11.
...
I would like to know what has been changed on IE11 which renders the implementation unusable and also if the solution I have quoted is the right and efficient one.javascript似乎按预期工作,并在IE9之前检索所有IE浏览器中的实际值,但似乎无法在IE11上工作。 ...我想知道在IE11上发生的变化导致实现无法使用,以及我引用的解决方案是否正确且有效。
You should have had that problem with IE8 as well. Through IE7, IE had a bug: It found elements using getElementById
that didn't have the id
you asked for, but did have a name
that matched. That is, in IE8 and earlier:
你也应该对IE8有这个问题。通过IE7,IE有一个错误:它发现使用getElementById的元素没有你要求的id,但确实有一个匹配的名字。也就是说,在IE8及更早版本中:
<input name="foo">
...would be found by document.getElementById("foo")
.
...将由document.getElementById(“foo”)找到。
This was a bug (although for a while Microsoft called it a feature, and documented it), and it was fixed.
这是一个错误(虽然有一段时间微软称之为功能,并记录了它),并且它已得到修复。
More (on my blog):
更多(在我的博客上):
- ...by any other name, would smell as sweet
......用任何其他名字,闻起来都很甜
#1
The javascript seems to work as expected and retrieves the actual value in all IE browsers until IE9, but seems to fail to work on IE11.
...
I would like to know what has been changed on IE11 which renders the implementation unusable and also if the solution I have quoted is the right and efficient one.javascript似乎按预期工作,并在IE9之前检索所有IE浏览器中的实际值,但似乎无法在IE11上工作。 ...我想知道在IE11上发生的变化导致实现无法使用,以及我引用的解决方案是否正确且有效。
You should have had that problem with IE8 as well. Through IE7, IE had a bug: It found elements using getElementById
that didn't have the id
you asked for, but did have a name
that matched. That is, in IE8 and earlier:
你也应该对IE8有这个问题。通过IE7,IE有一个错误:它发现使用getElementById的元素没有你要求的id,但确实有一个匹配的名字。也就是说,在IE8及更早版本中:
<input name="foo">
...would be found by document.getElementById("foo")
.
...将由document.getElementById(“foo”)找到。
This was a bug (although for a while Microsoft called it a feature, and documented it), and it was fixed.
这是一个错误(虽然有一段时间微软称之为功能,并记录了它),并且它已得到修复。
More (on my blog):
更多(在我的博客上):
- ...by any other name, would smell as sweet
......用任何其他名字,闻起来都很甜