블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

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 30 31
반응형

Category

Recent Post

Recent Comment

Archive

'.Net Project/.Net 3.5 Sp1'에 해당되는 글 45

  1. 2009.08.13 71장 문자열관련함수
  2. 2009.08.13 70장 날짜관련내장객제
  3. 2009.08.13 69장 JavaScript Event
  4. 2009.08.13 68장 익명(Anymous)
2009. 8. 13. 18:07 .Net Project/.Net 3.5 Sp1
반응형



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
  
        var s = "Abc Def Fed Cba";
        document.writeln(s.length); //길이
        document.writeln(s.toUpperCase()); //대문자
        document.writeln(s.toLowerCase()); //소문자 출력
        document.writeln(s.bold());
        document.writeln(s.italics());
        document.writeln(s.charAt(1)); //1번째 인덱스 : A, Indexof()
        document.writeln(s.substr(1, 3)) //1번째부터 3자 : sbstr
        document.writeln(s.indexOf("b"));
        document.writeln(s.replace("Abc", "에이비씨")); //치환
       
        var arr = s.split(' ');
        for (var i = 0; i < arr.length; i++) {
            document.writeln(arr[i]);
        }
       
       
        ///퀴즈 ) 아래 dir변수에서 파일명과 확장자를 추출해서 출력하시오
        var dir = "C:\\Temp\\RedPlus.gif";
        var fullname = dir.substr(dir.lastIndexOf("\\") + 1);
        var name = fullname.substr(0, fullname.lastIndexOf("."));
        var ext = fullname.substr(fullname.lastIndexOf(".") + 1);
        document.writeln("전체 :" + fullname);
        document.writeln("일반 :" + name);
        document.writeln("확장자 :" + ext);                   
    
</script>   
</head>
<body>
</body>
</html>

반응형

'.Net Project > .Net 3.5 Sp1' 카테고리의 다른 글

73장 네임스페이스(NameSpace)  (0) 2009.08.15
72장 Class 관련 복습  (0) 2009.08.15
70장 날짜관련내장객제  (0) 2009.08.13
69장 JavaScript Event  (0) 2009.08.13
68장 익명(Anymous)  (0) 2009.08.13
posted by Magic_kit
2009. 8. 13. 18:05 .Net Project/.Net 3.5 Sp1
반응형

살아온 날수 구하기

생일을 입력하세요



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        function isDate(y, m, d) {
            //매개변수가 숫자가 아니면 거짓
            if (isNaN(y) || isNaN(m) || isNaN(d)) {
                return false;

            }
            //매개변수로 날짜 객체 생성
            Dates = new Date(y, m-1, d)

            if (!(parseInt(Date.getFullYear()) == y && parseInt(Dates.getMonth() + 1) == m && parseInt(Dates.getDate()) == d)) {
                return false;
            }
            return true;
            }           

         function formatNumber(val) {
                //숫자가 아니면 0으로 초기화
                if(isNaN(val)) val=0;
               
                //문자열을 숫자로 변환
                val = parseInt(val);
               
                //숫자를문자열로 변환
                str = val.toString(10);
               
                //마지막자릿수 추가
                ret = str.charAt(str.lengh-1);
                for(i=2 ; i<str.lengh;i++)
                {
                    //뒤로 세번째 자리마다,를 앞에 붙임
                    if (i % 3 == 1) {
                        ret = "," + ret;
                        //문자를 하나씩 앞에 붙임
                        ret = str.charAt(str.length - i) + ret;
                    }
                    return ret;
                }

                function checkForm() {
                    if (!isDate(document.f1.y.value, document.f1.m.value, document.f1.d.value)) {
                        alert('날짜에 오류');
                        document.f1.y.focus();
                    }
                    else {
                        birth = new Date(document.f1.y.value, document.f1.m.value - 1, document.f1.d.value)
                        today = new Date();
                        days = (today - birth) / 86400;
                        days /= 1000;
                        alert("당신은" + formatNumber(days) + "일을 살았습니다.");
                    }
                    return false;
                }                                
                   
               
             //현재 시간을 출력
        var today = new Date();

        //출력
        document.write(today.getFullYear() + "<br />");
        document.write((today.getMonth() + 1) + "<br />");
        document.write(today.getDay() + "<br />"); //0요일 ~ 6요일(토)
        document.write(today.getHours() + "<br />");
        document.write(today.getMinutes() + "<br />");
        document.write(today.getSeconds() + "<br />");
        document.write(today.getMilliseconds() + "<br />");

        //자바스크립트 확장
        //data.js검색 및 사용
        //날짜관련하여 data.js파일이 가장 많이 사용
        //var il = Date.getDaysInMonth(2009, 2-1);
        //document.write(il + "<br />");
          
       
        
 </script>
</head>
<body>

<h3>살아온 날수 구하기 </h3>

<form name = f1 method = post onsubmit="checkForm();">

생일을 입력하세요
<input type="text" name="y" size=4 maxlength="4" />년
<input type="text" name="m" size=2 maxlength="2" />월
<input type="text" name="d" size=2 maxlength="2" />일
<input type = "submit" name="send" />

</form>
</body>
</html>

반응형

'.Net Project > .Net 3.5 Sp1' 카테고리의 다른 글

72장 Class 관련 복습  (0) 2009.08.15
71장 문자열관련함수  (0) 2009.08.13
69장 JavaScript Event  (0) 2009.08.13
68장 익명(Anymous)  (0) 2009.08.13
67장 제네릭 메서드  (0) 2009.08.13
posted by Magic_kit
2009. 8. 13. 17:49 .Net Project/.Net 3.5 Sp1
반응형




Click mouse over DbClick
MouseDown(네이버) Mousemove MouseUp

즐겨찾기



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type ="text/javascript">
        function Go() {location.href = "
http://www.naver.com/"; }
    </script>
</head>
<body onload ="alert('어서오세요');" onunload="alert('감사합니다');">

    <table border="1" width=100>
   
    <tr>
        <td onclick="window.alert('Click');">Click</td>
        <td onmouseover ="this.style.backgroundColor='#66FF99' ;"
            onmouseout = "this.style.backgroundColor='';">mouse over</td>
           
        <td ondblclick="this.style.fontWeight = 'bold';">DbClick</td>
    </tr>
   
    <tr>
        <td onmousedown="Go();">MouseDown(네이버)</td>
        <td onmousemove="alert('꽝');">Mousemove</td>
        <td onmouseup="window.open('http://www.naver.com','','');">MouseUp</td>
    </tr>
   
    <tr>
        <td >
             <input type="text" onkeyup="alert(this.value)" maxlength="1" />
        </td>
           
        <td>
            <input type ="text" onkeypress="alert(this.value)" maxlength="1" />
        </td>
        <td>
            <input type ="text" onkeydown="alert(this.value)" maxlength="1" />
        </td>
    </tr>
   
    <tr>
        <td>
            <input type ="button" value="포커스" onfocus="this.style.border='1px solid red';"
                onblur="this.style.border='1px dotted gray';" />
        </td>
       
        <td>
            <input type="text" value="1234" onchange="alert('쉬는시간~');" />
        </td>
       
        <td>
        </td>
    </tr>
       
    </table>
    <script>
        function GoGo(url) {
            location.href = url;
        }
   
    </script>
   
   
    <h2>즐겨찾기</h2>
   
    <select onchange="GoGo(this.value);">
        <option value="
http://www.naver.com/">네이버</option>
        <option value="
http://www.google.com/">구글</option>
    </select>

    <!--블록설정하였을때 메시지박스 1234 표시-->
    <input type ="text" onselect="alert(this.value);" value="1234" />

</body>
</html>

반응형

'.Net Project > .Net 3.5 Sp1' 카테고리의 다른 글

71장 문자열관련함수  (0) 2009.08.13
70장 날짜관련내장객제  (0) 2009.08.13
68장 익명(Anymous)  (0) 2009.08.13
67장 제네릭 메서드  (0) 2009.08.13
66장 이벤트(Event)  (0) 2009.08.13
posted by Magic_kit
2009. 8. 13. 13:26 .Net Project/.Net 3.5 Sp1
반응형



using System;

//선언
public delegate void SayHandler(string msg);
public class Button
{
    //이벤트 생성
    public event SayHandler Click;
    //이벤트 핸들러 생성
    public void OnClick(string msg)
    {
        if (Click != null)
        {
            Click(msg);
        }
    }

}

public class Program
{
    public static void Say(string msg)
    {
        Console.WriteLine(msg);

    }
    public static void Main()
    {
        //1.메서드 호출
        //Program.Say("안녕");
        Say("안녕Say");

        //2.대리자를 통해서 대신 호출
        SayHandler sh = new SayHandler(Say);
        sh += new SayHandler(Program.Say);
        sh("방가Say"); //실행

        //3. 이벤트와 이벤트처리기를 통하서 등록해서 호출
        Button btn = new Button();
        btn.Click += new SayHandler(Say); //기본
        btn.Click += Say; //축약형
        btn.OnClick("Say");

        //4.무명 메서드
        SayHandler hi = delegate(string msg)
        {
            Console.WriteLine(msg);
        };
        hi("안녕 string msg");
        hi("방가 string msg");

        /////////////// 다른 방식 ///////////
        Button button = new Button();
        button.Click += delegate(string msg)
        {
            Console.WriteLine(msg);

        };

        button.Click += delegate(string msg)
        {
            Console.WriteLine(msg);

        };
        button.OnClick("string msg");
    }

}

반응형

'.Net Project > .Net 3.5 Sp1' 카테고리의 다른 글

70장 날짜관련내장객제  (0) 2009.08.13
69장 JavaScript Event  (0) 2009.08.13
67장 제네릭 메서드  (0) 2009.08.13
66장 이벤트(Event)  (0) 2009.08.13
65장 델리게이트(delegate)  (0) 2009.08.13
posted by Magic_kit