首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

使用prototype.js的有关问题

2012-03-13 
使用prototype.js的问题各位大哥,我初次使用prototype,但是以下代码一直出不来对话框,帮帮忙了我用的是ie7

使用prototype.js的问题
各位大哥,我初次使用prototype,但是以下代码一直出不来对话框,帮帮忙了
我用的是ie7.0       prototype1.5.1
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
        <script   src= "prototype.js "   type= "text/javascript "> </script>
        <script   language= "javascript "   type= "text/javascript ">

var   Person   =   Class.create();   //   类的声明                        
Person.prototype   =   {                                                                
      initialize:   function(name)   {     //   构造函数                
          this.name   =   name;                                                      
      }                                                                                              
      printName:   function()   {     //   成员函数                          
          alert(this.name);                                                  
      }                                                                                          
}                                                                                                    
var   persone   =   new   Person( "Joe   Smith ");//   创建实例          
persone.printName();   //   函数调用        
alert( "aaa ");
</script>
</head>

<body>
</body>
</html>


[解决办法]
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
<script src= "prototype.js " type= "text/javascript "> </script>
<script language= "javascript " type= "text/javascript ">



var Person = Class.create(); // 类的声明
Person.prototype = {
initialize: function(name) { // 构造函数
this.name = name;
},
printName: function() { // 成员函数
alert(this.name);
}
}
var persone = new Person( "Joe Smith ");// 创建实例
persone.printName(); // 函数调用
alert( "aaa ");
</script>
</head>

<body>
</body>
</html>
//少了一个,号
[解决办法]
}
printName: function() { // 成员函数

这里

},
printName: function() { // 成员函数

热点排行