我以下的代碼在運行時會出現錯誤,不果將ALERT("yyo");去掉的話就不會出錯,不去就會出錯.[code=JScript]
function goUrl(id)
{
alert (id+"  "+<%=page+0%>);
if (id == 'L')
alert("yyo"); #就是此句
window.location.href ("repPbi_1.asp?id="+<%=session("zongye")+0%>);
else
if (id == "F")
window.location.href ("repPbi_1.asp?id=1");
    else
if (id== "P")
window.location.href ("repPbi_1.asp?id="+<%=page-1%>);
else
window.location.href ("repPbi_1.asp?id="+<%=page+1%>);

}
[code]

解决方案 »

  1.   

    if...else...不匹配导致,建议lz编码时养成良好习惯,都加中括号
    function goUrl(id) 

        alert (id+"  "+ <%=page+0%>); 
        if (id == 'L'){ 
            alert("yyo"); #就是此句 
            window.location.href ("repPbi_1.asp?id="+ <%=session("zongye")+0%>); 
        }else{ 
            if (id == "F"){ 
                window.location.href ("repPbi_1.asp?id=1"); 
            }else if (id== "P"){ 
                window.location.href ("repPbi_1.asp?id="+ <%=page-1%>); 
            }else{ 
                window.location.href ("repPbi_1.asp?id="+ <%=page+1%>); 
            }
        }
    }
      

  2.   


    function goUrl(id) 

        alert (id+"  "+ <%=page+0%>); 
        if (id == 'L'){ 
            alert("yyo"); #就是此句 
             window.location.href ("repPbi_1.asp?id="+ <%=session("zongye")+0%>); 
        }else if (id == "F"){ 
            window.location.href ("repPbi_1.asp?id=1"); 
        }else if (id== "P"){ 
            window.location.href ("repPbi_1.asp?id="+ <%=page-1%>); 
        }else{ 
            window.location.href ("repPbi_1.asp?id="+ <%=page+1%>); 
        } 
    }