반응형
/** * 브라우저의 버전을 체크합니다. */ function getbrowser() { var tempdocument = window.document; if (tempdocument.all && tempdocument.getelementbyid) // 인터넷 익스플로러 5.x { return 1; } else if (tempdocument.all && !tempdocument.getelementbyid) // 인터넷 익스플로러 4.x { return 2; } else if (tempdocument.getelementbyid && !tempdocument.all) // 넷스케이프 6 { return 3; } else if (tempdocument.layers) // 넷스케이프 4.x { return 4; } } /** * 팝업창을 원하는 위치에 생성합니다. */ function openwindow(url, name, width, height, align, valign, option) { var x,y; var window_option = "width="+width+",height="+height; if (option!=null) window_option+=","+option; if (align==null) align="center"; if (valign==null) valign="center"; if (align=="left") x=0; else if (align=="right") x=(screen.width-width); else if (align=="center") x=(screen.width-width)/2 if (valign=="top") y=0; else if (valign=="bottom") y=(screen.height-height); else if (valign=="center") y=(screen.height-height)/2 window_option+=",left="+x+",top="+y; var win = window.open(url,name,window_option); focus(); win.focus(); return win; } /** * 윈도우가 열려있는지 체크합니다. */ function isalivewindow(win) { if (!win.closed) return true; else return false; } /** * 사운드를 들을수 있는지 환경인지 체크합니다. (ie전용) */ function enablesound() { document.write(""); return player64.issoundcardenabled(); } /** * 리얼플레이어(realplayer) 설치 여부 체크합니다. */ function enablerealplayer() { var nrealmode=0; var nrealplayer5=0; var nrealplayer4=0; var nrealplayerg2=0; if (window.document.all) // ie { document.write(' \n'); } else // ns { var numplugins = navigator.plugins.length; for (var i = 0; i < numplugins; i++) { plugin = navigator.plugins[i]; if (plugin.name.substring(0,10)=="realplayer") { nrealmode=1; } } } if (nrealmode || nrealplayerg2 || nrealplayer5 || nrealplayer4) return true; else return false; } /** * 페이지 이동을 합니다. * @param delay 페이지 이동 지연 시간 (milliseconds) */ function movepage(str,delay) { if (delay==null) window.location.href=str; else window.setinterval("window.location.href='"+str+"'",delay); } /** * 현재 히스토리 엔트리에 페이지를 읽어들입니다. (뒤로가기 버튼 비활성화) */ function replacepage(str,delay) { if (delay==null) window.location.replace(str); else window.setinterval("window.location.replace('"+str+"')",delay); } /** * 현재 페이지 새로 고침 */ function reloadpage(delay) { if (delay==null) window.location.reload(); else window.setinterval("window.location.reload()",delay); } /** * 문자열을 클립보드에 복사합니다. (ie전용) */ function copytoclip(str) { if (window.document.all) // ie일때 window.clipboarddata.setdata('text',str); } /** * 브라우저의 시작페이지 변경창을 띄웁니다. (ie전용) */ function sethomepage(url) { window.document.write(""); window.document.all.objhomepage.sethomepage(url); } /** * 브라우저의 즐겨찾기 추가창을 띄웁니다. (ie전용) */ function addfavorite(url, homename) { window.external.addfavorite(url, homename); } /** * 모니터 해상도를 구합니다. */ function getwindowresolution() { if (window.screen) { var returnarray = new array(2); returnarray[0] = window.screen.width; returnarray[1] = window.screen.height; return returnarray; } else return false; } /** * 사용자의 색상 설정을 구합니다. * @return 색상비트수를 반환합니다. ( 8비트 : 256색, 16비트 : 하이컬러 , 24비트 : 트루컬러 ) */ function getwindowcolor() { if (window.screen) { return screen.colordepth; } } /** * 브라우저의 제목표시줄을 설정합니다. */ function setwindowtitle(str) { document.title = str; } /** * 브라우저의 제목표시줄의 문자열을 반환합니다. */ function getwindowtitle() { return document.title; } /** * 브라우저의 상태표시줄을 설정합니다. */ function setstatustitle(str) { window.status = str; } /** * 브라우저의 상태표시줄의 문자열을 반환합니다. */ function getstatustitle() { return window.status; } /** * 한글 마지막 글자의 중성 유무를 체크합니다. * * ex ) var str = "사탕"; * if (checkfinalconsonant(str)) { * window.alert(str+"을 먹었습니다."); * } * else { * window.alert(str+"를 먹었습니다."); * } */ function checkfinalconsonant(str) { var strtemp = str.substr(str.length-1); if ((strtemp.charCodeAt(0)-16)%28!=0) return true; else return false; } /** * 문자열에 사용해서는 안되는 html태그가 있는지 체크합니다. */ function isvalidhtml(str) { var re = new regexp("<[\/]{0,1}[^\f\n\r\t\v]*(html|table|tr|td|script|form|xmp|!|iframe|textarea|input|meta)[^\f\n\r\t\v]*","gi"); var matcharray = str.match(re); if (matcharray) return false; else return true; } /** * 올바른 메일형식인지 체크합니다. */ function isvalidemail(str) { var re=new regexp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$","gi"); var matcharray=str.match(re); if (matcharray) return true; else return false; } /** * 올바른 홈페이지형식인지 체크합니다. */ function isvalidhomepage(str) { var re=new regexp("^((ht|f)tp:\/\/)((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((\/|\\?)[a-z0-9~#%&'_\+=:\?\.-]*)*)$","gi"); var matcharray=str.match(re); if (matcharray) return true; else return false; } /** * 올바른 전화번호 형식(숫자-숫자-숫자)인지 체크합니다. */ function isvalidphone(str) { if (str.search(/^(\d+)-(\d+)-(\d+)$/g)!=-1) return true; else return false; } /** * 알파벳만으로 구성된 문자열인지 체크합니다. */ function isalphabet(str) { if (str.search(/[^a-za-z]/g)==-1) return true; else return false; } /** * 대문자로만 구성된 문자열인지 체크합니다. */ function isuppercase(str) { if (str.search(/[^a-z]/g)==-1) return true; else return false; } /** * 소문자로만 구성된 문자열인지 체크합니다. */ function islowercase(str) { if (str.search(/[^a-z]/g)==-1) return true; else return false; } /** * 한글로만 구성된 문자열인지 체크합니다. */ function iskorean(str) { var strlength = str.length; var i; var unicode; for (i=0;i
반응형
'프론트엔드 > Java Script, jQuery, AJAX' 카테고리의 다른 글
JavaScript: 날짜 Validation 체크 (0) | 2014.01.01 |
---|---|
JavaScript 영문, 숫자 체크 (0) | 2013.12.24 |
JavaScript 오늘 하루는 이 창을 보지 않습니다. (0) | 2013.12.18 |
JavaScript 함수 호출과 매개변수를 이용한 Input 초기화 방법 (0) | 2013.12.18 |
JavaScript Object 객체 활용법 (0) | 2013.12.18 |
WRITTEN BY
,