我目前在學習面向對象的Javascript,但似乎警報不起作用。這裏有什麼問題?Javascript警告框未顯示
<
html>
<head>
<script>
function professor(name, myLecture){
this.name = name;
this.myLecture = myLecture;
}
professor.prototype.display = function(){
return this.name + " is teaching " + this.myLecture;
};
function subjectList(subject){
this.subject = subject;
}
subjectList.prototype.showAll= function(){
var str = " " ;
for(var i = 0 ; i<subject.length; i++)
str+= this.subject[i].display();
return str;
};
var ListOfSubs = new subjectList([
new professor("Muy","Obprog")
]);
alert(ListOfSubs.showAll());
</script>
<body>
</body>
</head>
</html>
您是否在您使用的瀏覽器中打開了JavaScript調試器並查看是否有錯誤? – 2012-03-20 13:41:17
確保你的javascript沒有錯誤第一(ReferenceError:主題未定義 - 第17行) – Nacho 2012-03-20 13:41:22
使用調試器...我得到的錯誤是'主題未定義' – xandercoded 2012-03-20 13:41:57