⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zinheritexample3.htm

📁 java教程!作为学习的必须过程
💻 HTM
字号:
<html>
<head>
<title>Example</title>
        <script type="text/javascript" src="zinherit.js"></script>
</head>
<body>
<script type="text/javascript">
function ClassX() {
    this.messageX = "This is the X message.";

    if (typeof ClassX._initialized == "undefined") {
        
        ClassX.prototype.sayMessageX = function () {
            alert(this.messageX);
        };

        ClassX._initialized = true;
    }
}

function ClassY() {
    this.messageY = "This is the Y message.";

    if (typeof ClassY._initialized == "undefined") {
        
        ClassY.prototype.sayMessageY = function () {
            alert(this.messageY);
        };

        ClassY._initialized = true;
    }
}

function ClassZ() {
    ClassX.apply(this);
    ClassY.apply(this);
    this.messageZ = "This is the Z message.";

    if (typeof ClassZ._initialized == "undefined") {
        
        ClassZ.prototype.inheritFrom(ClassX);
        ClassZ.prototype.inheritFrom(ClassY);

        ClassZ.prototype.sayMessageZ = function () {
            alert(this.messageZ);
        };

        ClassZ._initialized = true;
    }
}

var objZ = new ClassZ();
objZ.sayMessageX();
objZ.sayMessageY();
objZ.sayMessageZ();
</script>
 
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -