2007-10-11
像java类风格的js
<SCRIPT LANGUAGE="JavaScript">
<!--
myClass=new function ()//区别之处
...{
var isLock=false;
function check(str)
...{
if(isLock) 
...{
alert('lock!'+" Go this way in "+str);
return false;
}
return true;
}
function reset()
...{
isLock=true;
}
this.property1='property1';
this.method=function()
...{
alert('mothod');
}
this.method1=function(str)
...{
if(!check(str))return;
isLock=true;
}
}
alert(myClass.property1);
myClass.method();
myClass.method1("first");
myClass.method1("second");
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript"> 
function myClass()//
...{
var isLock=false;
function check(str)
...{
if(isLock) 
...{
alert('lock!'+" Go this way in "+str);
return false;
}
return true;
}
function reset()
...{
isLock=true;
}
this.property1='property1';
this.method=function()
...{
alert('mothod');
}
this.method1=function(str)
...{
if(!check(str))return;
isLock=true;
}
} 
var obj=new myClass();
alert(obj.property1)
obj.method();
obj.method1("first");
obj.method1("second");

</SCRIPT> - 13:57
- 浏览 (19)
- 评论 (0)
- 分类: javascript
- 相关推荐







评论排行榜