본문 바로가기

javascript

datejs 사용하기 2011/11/04 2011/11/11 2011/10/28 2012/03/04 2011/10/28 true true true true 2011/11/05 2011/08/04 2011/11/05 2011/08/04 2011/11/01 2011/11/30 2011/12/01 2011/10/01 더보기
chrome 에서 jQuery loading 하기 function loadJQuery() { var oScript = document.createElement("script"); oScript.type = "text/javascript"; oScript.charset = "utf-8"; oScript.src = "http://code.jquery.com/jquery-1.6.2.min.js"; document.getElementsByTagName("head")[0].appendChild(oScript); } 더보기
javascript hash var sssnInfo = new Hash(); function Hash() { this.length = 0; this.items = new Array(); for (var i = 0; i < arguments.length; i += 2) { if (typeof(arguments[i + 1]) != 'undefined') { this.items[arguments[i]] = arguments[i + 1]; this.length++; } } this.setItemArr = function(arr, isClear) { if(isClear) this.clear; for (var i = 0; i < arr.length; i += 2) { if (typeof(arr[i + 1]) != 'undefined') { t.. 더보기
정규식 모음 Date Format (m/d/y) ^([\d]|1[0,1,2])/([0-9]|[0,1,2][0-9]|3[0,1])/\d{4}$ 12/21/2005 Decimal Number ^\d*[0-9](\.\d*[0-9])?$ 234.342 Document Filenames ^[a-zA-Z0-9-_\.]+\.(pdf|txt|doc|csv)$ world-domination.pdf E-mail Address ^([0-9a-zA-Z]+([_.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*(.){1}[a-zA-Z]{2,4})+$ HTML Color Codes ^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$ #00ccff Image Fil.. 더보기
[펌]파일첨부 버튼에 이미지 추가하기 function doUpfile() { form.upfile1.click(); form.upfile2.value=form.upfile1.value; } / 원문 : http://blog.garubi.com/13 더보기
폰트사이즈 변경 // 글자 크기 축소 function fnFontSizeMinus() { var body = jQuery(document.body); if (body) { var value = body.css('font-size'); value = parseInt(value, 10) = 16 ? 16 : parseInt(value, 10) + 1; body.css('fontSize', value + "px"); } } 더보기
정규식 2 우선 사용예는 다음과 같다. 예) function chk(pstr) { var chkRep = /....-..-../; alert!!(chkRep.test(pstr)); } 정규식은 다음과 같다. (1) ^ (caret) : 라인의 처음이나 문자열의 처음을 표시 예 : ^aaa (문자열의 처음에 aaa를 포함하면 참, 그렇지 않으면 거짓) (2) $ (dollar) : 라인의 끝이나 문자열의 끝을 표시 예 : aaa$ (문자열의 끝에 aaa를 포함하면 참, 그렇지 않으면 거짓) (3) . (period) : 임의의 한 문자를 표시 예 : ^a.c (문자열의 처음에 abc, adc, aZc 등은 참, aa 는 거짓) a..b.. 더보기
firebug 콘솔 사용 console.log.info(a); console.log.warn(b); console.log.error(c); console.log("value for a is %s and the value of b is %d", a, b) 이렇게 하면 잘 찍힌다. 이제 alert은 그만.... 더보기
[자바스크립트] location.href 와 location.replace 의 차이점 자바스크립트에서 페이지 이동 시킬때 location.href를 많이 사용한다. 하지만 location.replace 메세드도 종종 이용하는데 두가지의 차이점은 아래와 같다. 표#1 location.href location.replace 기능 새로운 페이지로 이동된다. 기존페이지를 새로운 페이지로 변경시킨다. 형태 속성 메서드 주소 히스토리 기록된다 기록되지 않는다. 사용예 location.href='abc.php' location.replace('abc.php') location.href는 객체의 속성이며, loaction.replace()는 메서드(함수)로 작동된다. href는 페이지를 이동하는 것이기 때문에 뒤로가기 버튼을 누른경우 이전 페이지로 이동이 가능하지만, replace는 현재 페이지를 새로.. 더보기
자바스크립트를 자바 클래스처럼 사용하도록 해주는 ... http://www.evanbyrne.com/article/class.js 더보기