함수선언, 객체 생성을 주로함.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | <HTML> <HEAD> <TITLE>객체를 정의하고 생성하는 자바스크립트 예제</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function time(hour, minute, second){ this.hour = hour; this.minute = minute; this.second=second; } //---> </SCRIPT> </HEAD> <BODY> <H2>객체를 정의하고 생성하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- mywatch = new time(12,23,34); document.write("<H3>"+"mywatch 객체의 속성"+"</H3>"); document.write("<H3>"+"시간 :"+mywatch.hour+"</H3>"); document.write("<H3>"+"분 :"+mywatch.minute+"</H3>"); document.write("<H3>"+"초 :"+mywatch.second+"</H3>"); yourwatch = new time(0,20,31); document.write("<H3>"+"yourwatch 객체의 속성"+"</H3>"); document.write("<H3>"+"시간 :"+yourwatch.hour+"</H3>"); document.write("<H3>"+"분 :"+yourwatch.minute+"</H3>"); document.write("<H3>"+"초 :"+yourwatch.second+"</H3>"); hiswatch = new time(9,30,1); document.write("<H3>"+"hiswatch 객체의 속성"+"</H3>"); document.write("<H3>"+"시간 :"+hiswatch.hour+"</H3>"); document.write("<H3>"+"분 :"+hiswatch.minute+"</H3>"); document.write("<H3>"+"초 :"+hiswatch.second+"</H3>"); watch1 = new time(4,5,3); document.write("<H3>"+"watch1 객체의 속성"+"</H3>"); document.write("<H3>"+"시간 :"+watch1.hour+"</H3>"); document.write("<H3>"+"분 :"+watch1.minute+"</H3>"); document.write("<H3>"+"초 :"+watch1.second+"</H3>"); //---> </SCRIPT> </BODY> </HTML> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <HTML> <HEAD> <TITLE>객체를 정의하고 생성하는 자바스크립트 예제</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function computer(cpu, ram, hdd){ this.cpu = cpu; this.ram = ram; this.hdd = hdd; } //---> </SCRIPT> </HEAD> <BODY> <H2>객체를 정의하고 생성하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- mycomputer = new computer('pentium-I',16,30); document.write("<H3>"+"mycomputer 객체의 속성"+"</H3>"); document.write("<H3>"+"CPU :"+mycomputer.cpu+"</H3>"); document.write("<H3>"+"RAM :"+mycomputer.ram+"</H3>"); document.write("<H3>"+"HDD :"+mycomputer.hdd+"</H3>"); yourcomputer = new computer('pentium-III',65,"1PB"); document.write("<H3>"+"yourcomputer 객체의 속성"+"</H3>"); document.write("<H3>"+"CPU :"+yourcomputer.cpu+"</H3>"); document.write("<H3>"+"RAM :"+yourcomputer.ram+"</H3>"); document.write("<H3>"+"HDD :"+yourcomputer.hdd+"</H3>"); //---> </SCRIPT> </BODY> </HTML> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <HTML> <HEAD> <TITLE>객체를 정의하고 생성하는 자바스크립트 예제</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function car(manufacture,model,color){ this.manufacture = manufacture; this.model = model; this.color = color; } //---> </SCRIPT> </HEAD> <BODY> <H2>객체를 정의하고 생성하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- mycar = new car("현대","소나타","흰색"); document.write("<H3>"+"나의 차입니다."+"</H3>"); document.write("<H3>"+"제조회사 :"+mycar.manufacture+"</H3>"); document.write("<H3>"+"모델 :"+mycar.model+"</H3>"); document.write("<H3>"+"색상 :"+mycar.color+"</H3>"); yourcar = new car("대우","레간자","비둘기색"); document.write("<H3>"+"당신의 차입니다."+"</H3>"); document.write("<H3>"+"제조회사 :"+yourcar.manufacture+"</H3>"); document.write("<H3>"+"모델 :"+yourcar.model+"</H3>"); document.write("<H3>"+"색상 :"+yourcar.color+"</H3>"); //---> </SCRIPT> </BODY> </HTML> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | <HTML> <HEAD> <TITLE>객체의 메소드를 사용하는 자바스크립트 예제입니다</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function time(hour, minute, second){ this.hour = hour; this.minute = minute; this.second=second; this.print = print } function print(){ document.write("<H3>"+"시간 :"+this.hour+"</H3>"); document.write("<H3>"+"분 :"+this.minute+"</H3>"); document.write("<H3>"+"초 :"+this.second+"</H3>"); } //---> </SCRIPT> </HEAD> <BODY> <H2>객체의 메소드를 사용하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- mywatch = new time(12,23,34); document.write("<H3>"+"mywatch 객체의 속성"+"</H3>"); mywatch.print() yourwatch = new time(10,21,10); document.write("<H3>"+"yourwatch 객체의 속성"+"</H3>"); yourwatch.print() //---> </SCRIPT> </BODY> </HTML> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | <HTML> <HEAD> <TITLE>객체의 메소드를 사용하는 자바스크립트 예제입니다</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function man(name, height, weight){ this.name = name; this.height = height; this.weight = weight; this.print = print } function print(){ document.write("<H3>"+"이름 :"+this.name+"</H3>"); document.write("<H3>"+"키 :"+this.height+"</H3>"); document.write("<H3>"+"몸무게 :"+this.weight+"</H3>"); } //---> </SCRIPT> </HEAD> <BODY> <H2>객체의 메소드를 사용하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- man1 = new man("둘리",170,65); document.write("<H3>"+"man1 객체의 속성"+"</H3>"); man1.print() man2 = new man("희동이",165,47); document.write("<H3>"+"man2 객체의 속성"+"</H3>"); man2.print() //---> </SCRIPT> </BODY> </HTML> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <HTML> <HEAD> <TITLE>객체의 메소드를 사용하는 자바스크립트 예제입니다</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function man(){ this.nam = prompt("이름","nam"); this.jik = prompt("직업","jik"); this.nai = prompt("나이","nai"); this.gen = prompt("성별","gen"); this.dis = dis } function dis(){ document.write("<H3>"+"이름 :"+this.nam+"</H3>"); document.write("<H3>"+"직업 :"+this.jik+"</H3>"); document.write("<H3>"+"나이 :"+this.nai+"</H3>"); document.write("<H3>"+"성별 :"+this.gen+"</H3>"); } //---> </SCRIPT> </HEAD> <BODY> <H2>객체의 메소드를 사용하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- tom = new man(); document.write("<H3>"+"tom 객체의 속성"+"</H3>"); tom.dis() //---> </SCRIPT> </BODY> </HTML> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | <HTML> <HEAD> <TITLE>객체의 메소드를 사용하는 자바스크립트 예제입니다</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function person(name, age, computer){ this.name = name; this.age = age; this.computer = computer; this.print = print; } function computer(cpu, ram, hdd){ this.cpu = cpu; this.ram = ram; this.hdd = hdd; } function print(){ document.write(" 이름 : "+this.name+" | "); document.write(" 나이 : "+this.age+" | "); document.write(" CPU 타입 : "+this.computer.cpu+" | "); document.write(" RAM 크기 : "+this.computer.ram+" | "); document.write(" 하드 디스크 : "+this.computer.hdd+"<p/>"); } //---> </SCRIPT> </HEAD> <BODY> <H2>객체의 메소드를 사용하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- pc = new computer("i5","8GB","1TB"); man = new person("컴퓨터","나이",pc); man.print(); //---> </SCRIPT> </BODY> </HTML> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <HTML> <HEAD> <TITLE>객체의 메소드를 사용하는 자바스크립트 예제입니다</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function person(name, age, sex, birth){ this.name = name; this.age = age; this.sex = sex; this.birth = birth; this.print = print; } function birth(year, month, day){ this.year = year; this.month = month; this.day = day; } function print(){ document.write(" 이름 : "+this.name+" | "); document.write(" 나이 : "+this.age+" | "); document.write(" 성별 : "+this.sex+" | "); document.write(" 생년 : "+this.birth.year+" | "); document.write(" 생월 : "+this.birth.month+" | "); document.write(" 생일 : "+this.birth.day+"<p/>"); } //---> </SCRIPT> </HEAD> <BODY> <H2>객체의 메소드를 사용하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- friend_birth = new birth(2000,1,1); myfriend = new person("김빠생",5,"남자",friend_birth); myfriend.print(); //---> </SCRIPT> </BODY> </HTML> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <HTML> <HEAD> <TITLE>객체를 정의하고 생성하는 자바스크립트 예제</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function time(hour, minute, second){ this.hour = hour; this.minute = minute; this.second = second; } //---> </SCRIPT> </HEAD> <BODY> <H2>객체를 정의하고 생성하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- mywatch = new time(12,23,34); document.write("<H3>"+"mywatch 객체의 속성"+"</H3>"); document.write("<H3>"+"시간 :"+mywatch["hour"]+"</H3>"); document.write("<H3>"+"분 :"+mywatch["minute"]+"</H3>"); document.write("<H3>"+"초 :"+mywatch["second"]+"</H3>"); //---> </SCRIPT> </BODY> </HTML> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <HTML> <HEAD> <TITLE>객체를 정의하고 생성하는 자바스크립트 예제</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!------- function sinsang(name, age, juso){ this.name = name; this.age = age; this.juso = juso; } function print(obj){ for(var each_property in obj){ document.write("***"+obj[each_property]+" | "); } document.write("<P/>"); } //---> </SCRIPT> </HEAD> <BODY> <H2>객체를 정의하고 생성하는 자바스크립트 예제입니다</H2> <BR> <SCRIPT LANGUAGE="JavaScript"> <!------- hong = new sinsang("홍길동",20,"서율시"); kim = new sinsang("김갑돌",21,"경기도"); lee = new sinsang("이홍기",23,"대전시"); choi = new sinsang("최갑판",22,"광주시"); pak = new sinsang("박성환",24,"부산시"); document.write("<HR ALIGN = LEFT WIDTH = 15%>"); document.write("****** 친구 주소록 ******</HR>"); document.write("<HR ALIGN = LEFT WIDTH = 15%>"); document.write("**이름** **나이** **주소**</HR><br>"); document.write("------------------------------<br>"); print(hong); print(kim); print(lee); print(choi); print(pak); //---> </SCRIPT> </BODY> </HTML> | cs |
20150403 - 웹프로그래밍 기초 - 5주차.zip