我有一个在Windows Server 2000下运行的应用程序我不知道它使用的是哪个版本的IIS,但它看起来已经很老了。
我已经要求在IIS7.5下使用2012 Windows服务器
使其正常运行问题是应用程序的代码太旧了
这是一个例子
function validate(){
strFile = document.ValidForm.Search.value
if (strFile.length < 3) {
alert("You must type a value with at least 3 characters.");
document.ValidForm.Search.focus()
document.ValidForm.Search.select()}
else {
document.search_dg.action = "SomePerlFile.plx";
document.search_dg.Search.value = strFile;
document.search_dg.method = "post";
document.search_dgtarget = "results";
//document.search_dg.onsubmit = window.open('', 'winReq', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=500,height=500');
document.search_dgn.submit();
//document.search_dgn.target = "_self";
}
}
这部分代码在chrome和firefox下生成错误。我假设因为它已经老了
运行页面后,在Chrome调试器中,我收到了此行的错误
strFile = document.ValidForm.Search.value
Chrome声称(index):15 Uncaught TypeError: Cannot read property 'Search' of undefined
但是搜索框是在文档
中定义的<TABLE height="59" border="0" cellpadding="0" cellspacing="0">
<FORM ID="ValidForm" ACTION="" METHOD="POST" target="results" NAME="search_dgn" onSubmit="validate(); return false;">
<TR>
<TD width="176">
<INPUT TYPE="TEXT" NAME="Search" MAXLENGTH="100" style="width:100%">
</TD>
所以我最大的问题是,有什么方法可以配置我的IIS7.5以处理2000年以前存在的代码和东西吗?
我试图避免以最高成本更改代码(我非常确定如果我写document.getelementbyId它应该工作....)
但我瞄准的目标是制作ISS格式或处理......旧代代码
非常感谢任何形式的帮助和评论
答案 0 :(得分:1)
基于@Teemu的说法:
将{id>属性添加到input
字段:
<INPUT TYPE="TEXT" id="Search" NAME="Search" MAXLENGTH="100" style="width:100%">
然后使用
var strFile = document.getElementById('Search').value;
位于函数顶部以获取元素。
这与IIS无关。