这是一段测试JS写的类的作用域的例子
你的代码中多了个",",或者写成
<SCRIPT LANGUAGE="JavaScript">
<!--
function testBtn()
{
var obj = new Object();
obj.prototype = {
testproto:function()
{
alert("prototype");
},
testproto1:function()
{
alert("testproto1");
}
}
alert("before");
//下一句错误
//obj.testproto();
alert("after");
alert(obj.prototype);
obj.prototype.testproto1();
}
testBtn();
//-->
</SCRIPT>
你的代码中多了个",",或者写成
<SCRIPT LANGUAGE="JavaScript">
<!--
function testBtn()
{
var obj = new Object();
obj.prototype = {
testproto:function()
{
alert("prototype");
},
testproto1:function()
{
alert("testproto1");
}
}
alert("before");
//下一句错误
//obj.testproto();
alert("after");
alert(obj.prototype);
obj.prototype.testproto1();
}
testBtn();
//-->
</SCRIPT>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货