0

所以我有这个网页代码,它在 Firefox 中工作(有点),但只有选择在 IE8 中工作。为了让它在 Firefox 中正常工作,alert( null) 必须在那里,否则它不会hrefmyloc == "MySrch". 我没有收到任何反馈错误,这真的很令人困惑。

SqlStr = "Select DISTINCT Unit From Employee Where PhoneBook = 1 Order by Unit;"
Set UniNme = Connection.Execute(SqlStr)
Response.Write "<select id='Unit' onChange='Change(this.id)'>"
Response.Write "<option value=''>Choose Unit</option><br>"
Response.Write "<option value='Everyone'>Everyone</option><br>"
Do While Not UniNme.EOF
Response.Write "<option value='"&UniNme("Unit")&"'>"&UniNme("Unit")&"</option><br>"
UniNme.MoveNext
Loop
Response.Write "</select><br>"

Response.Write "Name Search: <input type='text' id='MySrch' onChange='Change(this.id)'>"

javascript函数是

function Change(myloc) {
if (myloc == "Unit") {
var myindex = document.getElementById(myloc).selectedIndex;
myvalue = document.getElementsByTagName("option")[myindex].value;
} else {
var myvalue = document.getElementById(myloc).value;
}

document.cookie = "Temp1="+escape(myloc);
document.cookie = "Temp2="+escape(myvalue);

document.location.href="AEmployees.asp?action=Change";

alert(null);
}
4

1 回答 1

0

看看 myvalue 变量的范围。它在这里具有本地可见性

else {
var myvalue = document.getElementById(myloc).value;
}

它可能不会导致问题,但它是潜在的危险代码

于 2013-05-08T11:16:12.213 回答