我刚开始学javascript,第一个实例就出现了这种恶心人问题,chrome、fireofx都弹出了这种警告窗口,如图,代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
// 'Lecture' 类的构造函数
function Lecture(name, teacher){
this.name = name;
this.teacher = teacher;
}// 'Lecture'类的一个方法
Lecture.prototype.display = function(){
return this.teacher + " is teacher " + this.name;
};
// 'Schedule'
function Schedule(lectures){
this.lectures = lectures;
}Schedule.prototype.display = function(){
var str = "";
for(var i=0; i<this.lectures.length; i++){
str += this.lectures[i].display + " ";
}
return str;
};
// main
var mySchedule = new Schedule([
   new Lecture("语言", "王蔷薇"),
   new Lecture("数字", "刘祥子"),
   new Lecture("英语", "布兰妮")
   ]);alert(mySchedule.display());
</script>
</head><body>
</body>
</html>

解决方案 »

  1.   

    str += this.lectures[i].display + " ";换成str += this.lectures[i].display() + " ";
      

  2.   

    Schedule.prototype.display = function(){
        var str = "";
        for(var i=0; i<this.lectures.length; i++){
            str += this.lectures[i].display()+ " ";
        }
        return str;
    };
      

  3.   

    <table id="tableid">
        <tr row="1"></tr>    
        <tr row="2"  selected="true"></tr>
        <tr row="3"></tr>
    </table>如何获取<tr row="2"  selected="true"></tr>  row值 
    那个好心的告诉下 我没分了 不能提问
      

  4.   


    document.getElementById("tableid").rows[1].getAttribute("row")
      

  5.   

    str += this.lectures[i].display + " ";这错了 加括号和不加括号意思完全就变了 加了就是执行函数体 不加 就是个function