Size: 1397
Comment:
|
Size: 1584
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 41: | Line 41: |
[DOM] core and HTML-DOM {{{ document.getElementsByTagName("form") document.forms element.getAttribute("src") element.src element.setAttribute("src", a) element.src = a }}} |
[DOM] Scripting. JeremyKeith 저서, 부제 WebDesign with JavaScript and the [DOM], 번역판 제목 DOM 스크립트
관련포스트
[http://channy.creation.net/blog/?p=431 DOM 스크립트 출간 이벤트]
주요내용
Node (nodeType)
- element (1)
- attribute (2)
- text (3)
꼭 알아야할 핵심 기본기
- 단계적 기능 축소 (Graceful degration) : 스크립트를 사용하지 않더라도 동작 가능한 웹문서 만들기
스크립트 분리 (Unobtrusive JavaScript) : 웹 문서 구조에서 동작 분리하기
- 하위 호환성 (Backwards compatibility) : 구 웹 브라우저에서도 동작 가능하도록 확인하기
위 내용을 준수한 팝업 윈도우 스크립트 (a tag에 class="popup"을 적은 후)
1 function popUp(winURL) {
2 window.open(winURL, 'Pop-up window', 'width=320, height=480');
3 return false;
4 }
5
6 window.onload = function() {
7 if (!document.getElementsByTagName) return false;
8 var links = document.getElementsByTagName('a');
9 for (var i=0; i<links.length; i++) {
10 if (links[i].className == "popup") {
11 links[i].onclick = function() {
12 return popUp(this.getAttribute('href'));
13 }
14 }
15 }
[DOM] core and HTML-DOM
document.getElementsByTagName("form") document.forms element.getAttribute("src") element.src element.setAttribute("src", a) element.src = a