<script type="text/javascript">
//<![CDATA[
function T()
{
this.i=0;
}//没有读写器 - 变向解决
T.prototype.set=function(n) {
this.i = n;
alert("ok");
}t=new T();
t.set(10);//重写输出方法即可
var _w = document.write;
document.write = function(s) {
_w(s);
alert("out");
}
document.write(t.i);
//]]>
</script>
//<![CDATA[
function T()
{
this.i=0;
}//没有读写器 - 变向解决
T.prototype.set=function(n) {
this.i = n;
alert("ok");
}t=new T();
t.set(10);//重写输出方法即可
var _w = document.write;
document.write = function(s) {
_w(s);
alert("out");
}
document.write(t.i);
//]]>
</script>
{
this.i=_i;
}
function _i(a,b,c)
{
return a+b+c;
}
--------------------------------function T()
{
this.i=function(a,b,c)
{
return a+b+c;
};
}
相当于 c# 的get 和set
但是ie下却没有,只能写成一个方法。function T(){
this.i=function{alert('do something')}
}
var T1=new T();
T1.i();
function Class()
{
this.a = 123;
this.b = 234;
var me = this;
this.sum = function ()
{
return me.a + me.b;
}();
}
var a = new Class()
alert(a.sum);
实际上都是一个函数.不知道Js怎么模拟?
function T(){
this.i=null;
this.j=null;
this.setI=function(sVal){
this.i=sVal;
}
this.getI=function(){
return this.i;
}
}