//getCookie 함수를 호출하여 쿠키값을 가져온다. var blnCookie = getCookie("member_gender"); //쿠키값이 true가 아닐 경우에만 새 창을 띄운다. if ( !blnCookie ) { window.open('cook.html','_blink','width=225,height=250,scrollbars=no,toolbar=no,left=0,top=0'); } </script> ---------여기까지------
새창에 들어갈 소스(cook.html) <html>
<head>
<script language="javascript"> //쿠키 생성 함수 function setCookie(name, value, expire) { var expire_date = new Date(expire) document.cookie = name + "=" + escape(value) + "; expires=" + expire_date.toGMTString(); }
//쿠키 소멸 함수 function clearCookie(name) { var today = new Date() //어제 날짜를 쿠키 소멸 날짜로 설정한다. var expire_date = new Date(today.getTime() - 60*60*24*1000) document.cookie = name + "= " + "; expires=" + expire_date.toGMTString() }
//체크 상태에 따라 쿠키 생성과 소멸을 제어하는 함수 function controlCookie(elemnt) { if (elemnt.checked) { //체크 박스를 선택했을 경우 쿠키 생성 함수 호출 setCookie("member_gender","true","July 18, 2010 00:00:00") //setTimeout("self.close()"); } else { //체크 박스를 해제했을 경우 쿠키 소멸 함수 호출 clearCookie("member_gender") } return } </script>
title|chapter|num|src 간단한 HTML 문서|chapter1|exnum1-1|exnumle1-1.html META 요소의 활용|chapter2|exnum2-1|exnumple2-1.html TITLE 요소의 의미|chapter2|exnum2-2|exnumple2-2.html BASE 요소의 활용|chapter2|exnum2-3|exnumple2-3.html 블럭요소의 활용|chapter3|exnum3-1|exnumple3-1.html PRE요소의 활용|chapter3|exnum3-2|exnumple3-2.html 모양지정 인라인요소|chapter3|exnum3-3|exnumple3-3.html 의미지정 인라인요소|chapter3|exnum3-4|exnumple3-4.html BR, NOBR, WBR 요소|chapter3|exnum3-5|exnumple3-5.html 객체요소(IMG,EMBED)|chapter3|exnum3-6|exnumple3-6.html TABLE 관련 요소|chapter4|exnum4-1|exnumple4-1.html FRAME 관련 요소와 속성|chapter4|exnum4-2|exnumple4-2.html
<script> function formatCurrency(arg){ n=String(arg) //소수점 파싱 시작 o=n.split(".")[0] p=n.split(".")[1] //파싱 끝 n="" //사용자가 임의로 넣은 콤마(,)제거 while(o.indexOf(",")!=-1){ o=o.replace(",","") } //제거 끝 //소수점 이상 부분 변환 d=o.length%3 for(i=0;i<o.length;i++){ if(i%3==d){ n+="," } n+=o.charAt(i) } if(!d){n=n.replace(n.charAt(0),"")} //변환 끝 //"소수점 이하가 있다면"조건부 시작 if(p){n+="."+p} //조건부 끝 return n }
function myFunction(obj){ obj.oldValue=obj.value obj.value=formatCurrency(obj.value) obj.dir="rtl" } function myFunction2(obj){ if(obj.oldValue){ obj.value=obj.oldValue } obj.select() obj.dir="ltr" } </script> <style> input{border:solid 1px black} </style> <body> <input type=text dir="rtl" onfocus="myFunction2(this)" onblur="myFunction(this)"><br> <input type=text dir="rtl" onfocus="myFunction2(this)" onblur="myFunction(this)"><br> <input type=text dir="rtl" onfocus="myFunction2(this)" onblur="myFunction(this)"><br> <input type=text dir="rtl" onfocus="myFunction2(this)" onblur="myFunction(this)"><br> vbscript에는 FormatCurrency()라는 자체 내장 함수가 있습니다<br> javascript에는 위와 같은 함수가 없기때문에 넷스케잎과의 호환을 위해<br> formatCurrency()라는 함수를 만들어 사용했습니다<br> 저는 엑셀 워크쉬트처럼 보이게 만들었는데 맘에 들지 모르겠네요<br> <input type=text>엘리먼트의 어트리뷰트중 dir(direction의 약자같죠?)의 속성은<br> ltr(left to right)과 rtl(right to left)이 있습니다<br> 테스트는 ie5.5 와 nn6(6.01)에서 했습니다 </body>
세로 길이 dialogHeight:sHeight Sets the height of the dialog window (see Remarks for default unit of measure).
가로 길이 dialogWidth:sWidth Sets the width of the dialog window (see Remarks for default unit of measure).
창의 왼쪽에서 떨어지는 위치 dialogLeft:sXPos Sets the left position of the dialog window relative to the upper-left corner of the desktop.
창의 상단에서 떨어지는 위치 dialogTop:sYPos Sets the top position of the dialog window relative to the upper-left corner of the desktop.
창의 중앙 위치 여부 - 기본값 Yes center:{ yes | no | 1 | 0 | on | off } Specifies whether to center the dialog window within the desktop. The default is yes.
인쇄나 미리보기시 표시 여부 - 기본값 No dialogHide:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window is hidden when printing or using print preview. This feature is only available when a dialog box is opened from a trusted application. The default is no.
안쪽 공간 여부 (sunken=있음, raised=없음) - 기본 값 raised edge:{ sunken | raised } Specifies the edge style of the dialog window. The default is raised.
도움말표시 여부 - 기본 값 Yes help:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays the context-sensitive Help icon. The default is yes.
창 넓이 조정 여부 - 기본 값 No resizable:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window has fixed dimensions. The default is no.
스크롤바 여부 - 기본 값 Yes scroll:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays scrollbars. The default is yes.
상태표시줄 여부 - 기본 값 Yes status:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays a status bar. The default is yes for untrusted dialog windows and no for trusted dialog windows.
창틀 여부 - 기본 값 No (웹브라우져에선 적용안됨.) unadorned:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays the border window chrome. This feature is only available when a dialog box is opened from a trusted application. The default is no.
/** * 입력값에 스페이스 이외의 의미있는 값이 있는지 체크 * ex) if (isEmpty(form.keyword)) { * alert("검색조건을 입력하세요."); * } */ function isEmpty(input) { if (input.value == null || input.value.replace(/ /gi,"") == "") { return true; } return false; }
/** * 입력값에 특정 문자(chars)가 있는지 체크 * 특정 문자를 허용하지 않으려 할 때 사용 * ex) if (containsChars(form.name,"!,*&^%$#@~;")) { * alert("이름 필드에는 특수 문자를 사용할 수 없습니다."); * } */ function containsChars(input,chars) { for (var inx = 0; inx < input.value.length; inx++) { if (chars.indexOf(input.value.charAt(inx)) != -1) return true; } return false; }
/** * 입력값이 특정 문자(chars)만으로 되어있는지 체크 * 특정 문자만 허용하려 할 때 사용 * ex) if (!containsCharsOnly(form.blood,"ABO")) { * alert("혈액형 필드에는 A,B,O 문자만 사용할 수 있습니다."); * } */ function containsCharsOnly(input,chars) { for (var inx = 0; inx < input.value.length; inx++) { if (chars.indexOf(input.value.charAt(inx)) == -1) return false; } return true; }
/** * 입력값이 알파벳인지 체크 * 아래 isAlphabet() 부터 isNumComma()까지의 메소드가 * 자주 쓰이는 경우에는 var chars 변수를 * global 변수로 선언하고 사용하도록 한다. * ex) var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; * var lowercase = "abcdefghijklmnopqrstuvwxyz"; * var number = "0123456789"; * function isAlphaNum(input) { * var chars = uppercase + lowercase + number; * return containsCharsOnly(input,chars); * } */ function isAlphabet(input) { var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; return containsCharsOnly(input,chars); }
/** * 입력값이 알파벳 대문자인지 체크 */ function isUpperCase(input) { var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; return containsCharsOnly(input,chars); }
/** * 입력값이 알파벳 소문자인지 체크 */ function isLowerCase(input) { var chars = "abcdefghijklmnopqrstuvwxyz"; return containsCharsOnly(input,chars); }
/** * 입력값에 숫자만 있는지 체크 */ function isNumber(input) { var chars = "0123456789"; return containsCharsOnly(input,chars); }
/** * 입력값이 알파벳,숫자로 되어있는지 체크 */ function isAlphaNum(input) { var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; return containsCharsOnly(input,chars); }
/** * 입력값이 숫자,대시(-)로 되어있는지 체크 */ function isNumDash(input) { var chars = "-0123456789"; return containsCharsOnly(input,chars); }
/** * 입력값이 숫자,콤마(,)로 되어있는지 체크 */ function isNumComma(input) { var chars = ",0123456789"; return containsCharsOnly(input,chars); }
/** * 입력값이 사용자가 정의한 포맷 형식인지 체크 * 자세한 format 형식은 자바스크립트의 `regular expression`을 참조 */ function isValidFormat(input,format) { if (input.value.search(format) != -1) { return true; //올바른 포맷 형식 } return false; }
/** * 입력값이 이메일 형식인지 체크 * ex) if (!isValidEmail(form.email)) { * alert("올바른 이메일 주소가 아닙니다."); * } */ function isValidEmail(input) { // var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/; var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/; return isValidFormat(input,format); }
/** * 입력값이 전화번호 형식(숫자-숫자-숫자)인지 체크 */ function isValidPhone(input) { var format = /^(\d+)-(\d+)-(\d+)$/; return isValidFormat(input,format); }
/** * 입력값의 바이트 길이를 리턴 * ex) if (getByteLength(form.title) > 100) { * alert("제목은 한글 50자(영문 100자) 이상 입력할 수 없습니다."); * } * Author : Wonyoung Lee */ function getByteLength(input) { var byteLength = 0; for (var inx = 0; inx < input.value.length; inx++) { var oneChar = escape(input.value.charAt(inx)); if ( oneChar.length == 1 ) { byteLength ++; } else if (oneChar.indexOf("%u") != -1) { byteLength += 2; } else if (oneChar.indexOf("%") != -1) { byteLength += oneChar.length/3; } } return byteLength; }
<script language="JavaScript"> ca_array = new Array(4); ca_array["1"] = new Array(new de_ca_array('0','하위카테고리'), new de_ca_array('11','DE_A1'), new de_ca_array('12','DE_A2')); ca_array["2"] = new Array(new de_ca_array('0','하위카테고리'), new de_ca_array('21','DE_B1'), new de_ca_array('22','DE_B2')); ca_array["3"] = new Array(new de_ca_array('0','하위카테고리'), new de_ca_array('31','DE_C1')); ca_array["4"] = new Array(new de_ca_array('0','하위카테고리'), new de_ca_array('41','DE_D1'));
function call_de_ca(f) { detail_category = f.category.options[f.category.selectedIndex].value; if (detail_category == "0") { for (i = 1; i < f.detail_category.options.length; i++) f.detail_category.options[i] = new Option(' ', '0'); f.detail_category.options[0].selected = true; return; } for (i = 0; i < ca_array[detail_category].length; i++) f.detail_category.options[i] = new Option(ca_array[detail_category][i].detail_name, ca_array[detail_category][i].detail_category); for (i = ca_array[detail_category].length; i < f.detail_category.options.length; i++) f.detail_category.options[i] = new Option(' ', '0'); f.detail_category.options[0].selected = true; } } </script>
listHighCG=newArray("대분류 선택","뉴스-미디어","엔터테이먼트","예술","정치 및 법","사회문화","경제","쇼핑","공짜&무료","컴퓨터,인터넷","가정-여성","레크리에이션","스포츠","학문-과학","건강-의학","교육","학교","종교","팬클럽","안티사이트");