既然是MM那么:
http://www.csdn.net/Develop/article/20%5C20150.shtm

解决方案 »

  1.   

    <HTML>
    <HEAD>
    <TITLE> My first JavaScript program </TITLE><SCRIPT LANGUAGE = JavaScript>
    function TestClass(){
        this.value="N/A";
    this.getValue = function (){
        return this.value ;
    }
    this.setValue = function (v){
        this.value=v;
    }
    }function testFunction(){
    var obj = new TestClass();
    obj.setValue("Hello, world...");
    window.alert(obj.getValue());
    }
    </SCRIPT></HEAD><BODY BGCOLOR="white">
    <H1>My first JavaScript program!</H1><a href="javascript:testFunction()">测试</a>
     
    </BODY>
    </HTML>
      

  2.   

    <html>
    <head>
    <title>面向对象的例子</title>
    </head>
    <body>
    <script lanaguage="javascript">
    //****************Begin define Class ****************************88
    function ObjectExample(name,color)
    {
        //define the property
        this.name=name
        this.color=color   //define behavier
        this.show=show
    }function show()
    {
        window.alert("name is: "+this.name+'\'+"color is :"+this.color)
    }//*****************************End of Defining *****************************function exam()
    {
       var oo=new ObjectExample('A','Red')
       oo.show()
    }</script>
    <a href="javascript:exam()>Test</a>
    </body>
    </html>
      

  3.   

    //*********************我这个你看看怎么样*******************************
    <script language="javascript">
    function CarSpeed(intSpeed) //这是车子行驶的速度,是car函数的一个方法
    {
    if(intSpeed<=0||!this.Engine)//如果引擎没有发动,或者引擎发送了,没有行驶速度就为0
    return "not run";else if(intSpeed>0&&intSpeed<=50)如果车子在0--50脉速度,那么车子的速度为中速。
    return "middle speed";else if(intSpeed>50&&intSpeed<=100)//依此类推
    return "high speed";else if(intSpeed>100)
    return "Super speed";}function Car(Cc,Ce) //车子的函数0
    {
    this.Color=Cc; //这里是车子的颜色
    this.Engine=Ce; //引擎是否启动
    this.Speed=CarSpeed //这里就是车子的事件
    return this; //返回当前对象的值
    }
    var obj=new Car("red",true) //用new关键字实例化
    with(document) //打印车子的信息。
    {
    write("车的颜色为:"+obj.Color+"<br>");
    write("引擎是否启动:"+obj.Engine+"<br>")
    write("速度等级:"+obj.Speed(50))
    }</script>