2016-12-15 37 views
1

我這裏有問題......JS意外標記其他

if (currentScreen=="object" && currentItem[1]!=null){ 
    gotoElement(currentItem[0], currentItem[1], true, false, currentScreen); 
} else { 
    loadContent("objectMain.php?objectClass=" + currentItem[0],"centerDiv"); 
} else { 
    target=getTargetFromCurrentScreen(currentScreen); 
    loadContent(target,"centerDiv"); 
} 

enableWidget('menuBarRedoButton'); 
if (historyPosition == 0) { 
    disableWidget('menuBarUndoButton'); 
} 

錯誤是:

「意外的標記別人」。

有人可以幫助我嗎?

+0

你不能有兩個人的 – George

回答

1

您對使用else if(),而不是兩個successif else的:

if (first_condition){ 

} else if(second_condition) { 

} else { 

} 

希望這有助於。

1

你有這樣的:

if (someCondition) { 

} else { 

} else { 

} 

這在邏輯上是沒有意義的。 else的意思是「在所有其他情況下」。那麼第二個else可能是什麼意思?

你可能意味着有if條件:

if (someCondition) { 

} else if (anotherCondition) { 

} else { 

}