我必须制作一个与 IE 5+ 兼容的网站,它必须与 IE5+ 兼容,因为我使用的设备使用 Windows CE 5 或 6,并且我无法将 IE 更新到更新的版本。
我编写了一个带有几个函数的 JavaScript 代码:
GiveFocus()
加载页面时,此函数将焦点分配给第一个文本字段。我知道这个功能有效。
CheckOne()
CheckTwo()
这些函数通过 OnKeyUp()
分配给文本字段
当按下键 13 时,(对于那些不知道键 13 的人来说,它是回车键)
它将焦点集中到下一个领域。这些功能在一定程度上也起作用。
当页面到达最后一个组件时,它会将焦点跳过到浏览器的 URL 栏
SubmitForm()
这是我担心的函数,在这个函数中我检查文本字段是否不为空,如果这些字段不为空,则将值赋予其他文本字段并且将提交表单。我担心浏览器与此代码不兼容。
代码如下所示:
function SubmitForm()
{
var locatie = document.getElementById("one").value;
var bonregel= document.getElementById("two").value;
if (locatie.length == 0)
{
ErrorMessage("Het locatieveld is niet ingevuld");
}
if (bonregel.length == 0) {
ErrorMessage("Het bonregelveld is niet ingevuld");
}
if (bonregel.length == 0 & locatie.length == 0)
{
ErrorMessage("Geen velden ingevuld");
}
else {
document.getElementById("locatie").value = locatie;
document.getElementById("bonregel").value = bonregel;
document.myform.submit();
}
}
function ErrorMessage(Message)
{
document.getElementById("errorSection").innerHTML = Message;
}
这是代码必须使用的 html:
<form name="myform" action="/" method="post" >
<input type="hidden" id="locatie" name="locatie" />
<input type="hidden" id="bonregel" name="bonregel" />
</form>
<table>
<tr>
<td>Locatie:</td>
<td><input type="text" id="one" onkeyup="CheckOne()" name="locatie" value="{locatie}" /></td>
</tr>
<tr>
<td>Bonregel:</td>
<td><input type="text" name="bonregel" id="two" onkeyup="CheckTwo()" /></td>
</tr>
</table>
<p id="errorSection">{errorSection}</p>
所以结论是,代码能工作吗?它是否可以与 IE5+ 一起使用,因为我无法在设备上测试它,因为我还没有它。
或者有没有办法获得 IE5,以便我可以在我的计算机上测试它?
最佳答案
Internet Explorer 11 Devtools 似乎允许您选择 IE5(颤抖)作为模式选项(如果这有任何帮助的话)。
尽管它与 15 年前的浏览器的相似度有待商榷。
这可能有帮助:http://tredosoft.com/Multiple_IE
它是旧 IE 版本的集合,尽管我不知道它们是否会在现代操作系统上并行安装。
关于javascript - 检查代码是否与 IE 5 兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30775075/