RSS구독하기:SUBSCRIBE TO RSS FEED
즐겨찾기추가:ADD FAVORITE
글쓰기:POST
관리자:ADMINISTRATOR
웹&컴퓨팅  2007/10/11 16:07

/**
 * 브라우저의 버전을 체크합니다.
 */


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("<object id='player64' classid='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95' style='display:none'></object>");
  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('<script language=vbscript\> \n');
        document.write('on error resume next \n');
        document.write('nrealplayerg2 = (not isnull(createobject("rmocx.realplayer g2 control")))\n');
        document.write('nrealplayer5 = (not isnull(createobject("realplayer.realplayer(tm) activex control (32-bit)")))\n');
        document.write('nrealplayer4 = (not isnull(createobject("realvideo.realvideo(tm) activex control (32-bit)")))\n');
        document.write('</script\> \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("<span id='objhomepage' style='behavior:url(#default#homepage); display:none;' >s</span>");
    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<strlength;i++)
    {
        unicode = str.charcodeat(i);
        if ( !(44032 <= unicode && unicode <= 55203) ) return false;   
    }
    return true;
}


/**
 * 숫자만으로 구성된 문자열인지 체크합니다.
 */


function isdigit(str)
{
    if (str.search(/[^0-9]/g)==-1) return true;
    else return false;
}


/**
 * 문자열이 null인지 체크합니다.
 */


function isnull(str)
{
    if (str == null || str == "") return true;
    else return false;
}


/**
 * 문자열에 한칸이상의 스페이스 입력이 있는지를 체크합니다.
 */


function isvalidspace(str)
{
    if (isnull(str)) return false;
    else
    {
        if (str.search(/[\s]{2,}/g)!=-1) return false;
        else return true;
    }
}

2007/10/11 16:07 2007/10/11 16:07
http://www.x2chi.com/trackback/53
x2chi:Leading the Web to its Full Potential...
(웹의 모든 잠재력을 이끌어 내기 위하여...)
Leading the Web to its Full Potential... (웹의 모든 잠재력을 이끌어 내기 위하여...)
전체 (832)
내 이야기 (443)
관심거리들 (159)
웹&컴퓨팅 (173)
(주) 프로홈 (19)
건강 (7)
«   2012/02   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      
  1. generic cialis overnight  05:35
    Corporation began studying compound IC a phosph...
  2. cialis vs viagra vs levitra  05:35
    can decrease blood flow to the optic nerve of t...
  3. buy generic cialis  05:35
    Consider whether patients with underlying cardi...
  4. Jamie  04:37
    Salmeterol generic what does it look like, Salm...
  5. buy generic cialis in canada  04:30
    may cause dizziness drowsiness fainting or blur...
  1. x2chi's me2day  2011
    슈퍼스타의 생각
  2. x2chi's me2day  2011
    슈퍼스타의 생각
  3. x2chi's me2day  2011
    슈퍼스타의 생각
  4. x2chi's me2day  2010
    슈퍼스타의 생각
  5. x2chi's me2day  2010
    슈퍼스타의 생각
  1. 2012/01 (1)
  2. 2011/10 (1)
  3. 2011/09 (9)
  4. 2011/08 (16)
  5. 2011/07 (10)