본문 바로가기

Javascript

(4)
Javascript AJAX AJAX - 페이지 로드 후 웹서버에서 데이터를 읽음 - 페이지를 다시 로드하지 않고 웹페이지 업데이트가 가능 - 뒷단에 있는 웹서버로 데이터 전송 AJAX Example 원하는 정보를 로드 할 수 있는 버튼을 생성한다 Let AJAX change this text Change Content ajax_info.txt 파일에서 원하는 정보를 가져와 페이지에 보여줄 수 있도록 로드한다 function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("demo").innerH..
Javascript Browser BOM BOM은 Browser Object Model의 약자이다 window : 브라우저 윈도우 window.innerHeight - the inner height of the browser window (in pixels) window.innerWidth - the inner width of the browser window (in pixels) window.open() - open a new window window.close() - close the current window window.moveTo() - move the current window window.resizeTo() - resize the current window window.screen : 유저 스크린에 대한 정보 screen.width..
Javascript Form & HTML DOM Validation document.forms["myForm"]["fname"].value 로 form에 입력된 값을 가져와 유효검사할 수 있다 onsubmit="return validateForm() HTML에서는 생성한 함수를 불러줘야한다 checkValidity() 유효한 값이면 true를 리터난다 setCustomValidity() Sets the validationMessage property of an input element. Valid Properties html에서 설정한 유효한 범위의 값에 대해 판별한다 customError Set to true, if a custom validity message is set. patternMismatch Set to true, if an elemen..
Javascript : 자바스크립트는 스크립트 태그에 한데 모아서 작성할 수 있다. 와 두 곳 다 위치할 수 있다 getElementById() : id로 html 요소를 찾아 접근하는데에 쓰인다 id : html 요소 정의 innerHTML : html 요소안의 컨텐츠 정의 document.write() : 쉽게 html에 결과작성할 수 있지만 html 페이지 로드 후 사용된다면 현재 존재하는 html 페이지의 내용을 삭제해버리므로 test용도로 적절한 function window.alert() : 알림창 띄우기. window 키워드는 생략가능 console.log() : 브라우저가 데이타를 보여준다 (f12 -> Consol -> 새로고침하면 입력한 값을 볼 수 있다) window.print() : 현재 페이지를 인쇄할..