读书人

使用prototype.js的有关问题

发布时间: 2012-03-13 11:21:11 作者: rapoo

使用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() { // 成员函数

读书人网 >JavaScript

热点推荐