Programming/JavaScript(7)
-
Object Model(자바스크립트 개요), BOM, DOM
*document: , 등, 태그 이름 검색 기능 제공 getElementsByTagName()*BOM(Browser Object Model): alert나 confirm, prompt, window.open 같은 것*XMLHttpRequest(AJAX 통신의 주체) 1. BOM(브라우저 객체) 1) 새 창 열기window.open() 2) 창 크기 조절window.open(top,left,width,height 값 조절) 3) 새 창에 메시지 띄우기test.document.write('메시지'); 1234567891011121314window open(새 창 열기) 새 창 열기: window.open() 새 창 열기(크기 조절): window.open() 새 창 변수에 담기: window.open() ..
2016.11.28 -
상속(prototype)
상속은 propertype을 이용해 간단히 할 수 있다. Programmer.prototype = new Person(); 123456789101112131415161718192021222324//Person 객체function Person(name){ this.name = name;}Person.prototype.name=null;Person.prototype.introduce = function(){ return 'My name is '+this.name; } //프로그래머 생성자function Programmer(name){ this.name = name;} //프로그래머 생성, coding() 추가Programmer.prototype = new Person();Programmer.prototype..
2016.11.27 -
AJAX 정리
AJAX(Asynchronous JavaScript and XML)란 '비동기식 웹 통신'을 말함웹브라우저와 웹서버가 내부적으로 데이터 통신을 하기 때문에,서비스 요청시 페이지 일부만 로딩 가능 1) 이벤트 발생(ex. 버튼 클릭) 2) XMLHttpRequest가 생성됨 123var xhttp; //HttpRequest 객체 담을 변수 if(window.XMLHttpRequest){ xhttp = new XMLHttpRequest();cs 3) XMLHttpRequest가 웹서버에 요청 보냄 12xhttp.open("GET","books.xml",true); //접속할 파일 설정xhttp.send(); //접속, 성공시 onreadystatechange에 선언된 함수가 실행됨cs 4) 서버가 요청 처리..
2016.11.23 -
JSON 정리
JSON(JavaScript Object Notation):객체 형식으로 자료를 간결히 표현한 것(공식 표준인 XML보다 더 가볍기 때문에 자주 쓰임) 참고 사이트: http://genesis8.tistory.com/195 12345678910 01_a123 모비딕 소설 12900 쯔위 흰 고래 이야기 cs 12345678{"num" : "01_a123","name" : "모비딕","sort" : "소설","price" : "12000","author" : "쯔위","info" : "흰 고래 이야기"}cs 위에서 보듯같은 정보라도 JSON의 경우가 데이터가 가볍다. 1) 객체(object) 12345{"나이": 18, "이름":"쯔위", "여자니":true}cs 2) 배열 대괄호([])안에 콤마로 값, ..
2016.11.23 -
함수(Function)
**생활코딩:함수지향~클로저까지 복습할 것** 1) function의 특징: 자유로움(데이터 타입, return값, 형태 등)객체로도 되고 값으로도 사용될 수 있다. 123456789function cal(mode){ var funcs = { 'add' : function(a, b){return a + b}, 'subtract' : function(a, b){return a - b} } return funcs[mode];}alert(cal('add')(2,1));alert(cal('subtract')(2,1)); cs 123456789function sum(){ var i, _sum = 0; //arguments.length(배열 길이) for(i = 0; i
2016.11.23 -
문자열, 배열 처리
1) 문자열을 처리하는 함수를 사용해 보자 strVar: Start I am a String Variable End-------------------------------------- strVar.length: 32첫 번째 S 위치 : strVar.indexOf('S'): 0ㄴ다른 방법: strVar.search('S'): 0마지막 S 위치 : strVar.lastIndexOf('S'): 13-------------------------------------위치로 값 찾기1: strVar.charAt(3): r위치로 값 찾기2: strVar[3]: r------------------------------------- 8부터 10까지 자르기 : strVar.slice(8,10): amㄴ다른 방법(뒤에서부터..
2016.11.22