Windows 2000 VS IIS7.5 windows 2012 兼容性Javascript

Windows 2000 VS IIS7.5 windows 2012 compability Javascript

我有一个在 windows server 2000 下运行的应用程序我不知道它使用的是哪个版本的 IIS,但它看起来太旧了。

我被要求使用 2012 windows 服务器在 IIS7.5 下运行它

问题是应用程序的代码也太旧了

这是一个例子

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 格式或处理...老一代代码

非常感谢任何形式的帮助和评论

根据@Teemu 所说:

input 字段添加一个 id 属性:

<INPUT TYPE="TEXT" id="Search" NAME="Search" MAXLENGTH="100" style="width:100%">

然后使用

var strFile = document.getElementById('Search').value;

在函数顶部获取您的元素。

这应该与 IIS 无关。