一千萬個為什麽

搜索

為什麽這個ASP腳本不起作用?

你能告訴我這個ASP腳本有什麽問題:

我認為錯誤發生在 if 語句中

<script>
productID=new Array()
variaveis=location.search.replace(/\x3F/,"").replace(/\x2B/g," ").split("&")
if(variaveis!=""){
for(i=0;iflash1");
}
else if (flash = "flash2")
{
document.write("flash2");
}
else
{
document.write("another");
}
</script>

最佳答案

更換

if (flash = "flash1")

if (flash == "flash1")

等等

A single = is for assignment, not for testing equality. JSLint is a great tool for picking up these kinds of errors:

Error:
Problem at line 1 character 20: Use the array literal notation [].

productID=new Array()

Problem at line 1 character 22: Missing semicolon.

productID=new Array()

Problem at line 2 character 77: Missing semicolon.

variaveis=location.search.更換(/\x3F/,"").更換(/\x2B/g," ").split("&")

Problem at line 5 character 33: Missing semicolon.

nvar=variaveis[i].split("=")

Problem at line 6 character 41: Missing semicolon.

productID[nvar[0]]=unescape(nvar[1])

Problem at line 11 character 29: Missing semicolon.

return productID[variavel]

Problem at line 16 character 11: Expected a conditional expression and instead saw an assignment.

if (flash = "flash1")

Problem at line 20 character 16: Expected a conditional expression and instead saw an assignment.

else if (flash = "flash2")

Implied global: productID 1,6,11, variaveis 2,3,4,5, i 4,5, nvar 5,6, unescape 6

轉載註明原文: 為什麽這個ASP腳本不起作用?