'prototype 상속'에 해당되는 글 1건

  1. 2009.12.02 prototype 상속
반응형

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="utf-8">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>javascript :prototype 사용 변수 선언 </title>
  <script type="text/javascript" src="prototype.js"></script>
 
  <SCRIPT LANGUAGE="JavaScript">
   
  <!--

   function addLoadEvent(func) {
     var oldonload = window.onload;
     if (typeof window.onload != 'function') {
    window.onload = func;
     } else {
    window.onload = function() {
      oldonload();
      func();
    }
     }
   }

   var Subject = Class.create();


   Subject.prototype={
    initialize : function(name){
     this.name = name;
    }
   }

   var ChildSubject = Class.create();

   ChildSubject.prototype = Object.extend(
    new Subject,{
     showList : function(){
      var subjectList = new Array("XHTML","jsp","ajax");
      var console = document.getElementById("area");
      if(console != null){
       console.innerHTML += "<b>수강과목</b><br/>"+subjectList+"";
      } //if
     } //showList : function
    }//new Subject,
   );//ChildSubject.prototype


   function callFunction(){
    var childSubject = new ChildSubject("컴퓨터 공학과");
    childSubject.showList();
   }

   addLoadEvent(callFunction);

   

  //-->
  </SCRIPT>
 </head>
 <body>
  <div id="area"></div>
 </body>
</html>

Posted by 1010