336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

안녕하세요.

 

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
32
33
34
35
36
<!-- jquery를 불러옵니다. jquery.com download 페이지를 참조해주세요 -->
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
 
<script>
  $(document).ready(function() {
    $('#favorite').on('click'function(e) {
        var bookmarkURL = window.location.href;
        var bookmarkTitle = document.title;
        var triggerDefault = false;
 
        if (window.sidebar && window.sidebar.addPanel) {
            // Firefox version < 23
            window.sidebar.addPanel(bookmarkTitle, bookmarkURL, '');
        } else if ((window.sidebar && (navigator.userAgent.toLowerCase().indexOf('firefox'> -1)) || (window.opera && window.print)) {
            // Firefox version >= 23 and Opera Hotlist
            var $this = $(this);
            $this.attr('href', bookmarkURL);
            $this.attr('title', bookmarkTitle);
            $this.attr('rel''sidebar');
            $this.off(e);
            triggerDefault = true;
        } else if (window.external && ('AddFavorite' in window.external)) {
            // IE Favorite
            window.external.AddFavorite(bookmarkURL, bookmarkTitle);
        } else {
            // WebKit - Safari/Chrome
            alert((navigator.userAgent.toLowerCase().indexOf('mac'!= -1 ? 'Cmd' : 'Ctrl'+ '+D 키를 눌러 즐겨찾기에 등록하실 수 있습니다.');
        }
 
        return triggerDefault;
    });
});
</script>
 
<a href="#" id="favorite" title="즐겨찾기 등록">즐겨찾기</a>
cs

 

감사합니다.

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

안녕하세요.

 

selectbox에 있는 값을 가져오거나 선택한 것을 가져오는 소스코드입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script>
    window.onload = function(){
 
        //차례대로 
        //선택한순서
        //옵션(select박스 안쪽에 있는 값을 가져오기 위함입니다.
        //값을 가져옵니다.
        var x = document.getElementById("mySelect").selectedIndex;
        var y = document.getElementById("mySelect").options;
        var z = document.getElementById("mySelect").value;
 
        //순서대로 값을 띄워줍니다.
        alert("Index: " + y[x].index + " is " + y[x].text+" is " + z);
 
    }
</script>
<select id="mySelect">
    <option value="Banana1!">Banana</option>
    <option value="값">값 선택</option>
 
</select>
 
cs

 

감사합니다.

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

안녕하세요.

이번에는 url 주소창 값을 통해서 필요한 처리를 하는 방법을 알려드릴께요.

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
32
33
34
<script>
    window.onload = function(){
 
        //해당 일치하는 부분을 호출해 옵니다. 필요한 부분을 가져다가 쓰시면됩니다
        //ex)
        if(location.href == "http://jdkblog.tistory.com"){
            alert('해당 페이지로 이동합니다');
            location.href = location.href;
        }
        //-javascript-
 
        //location.href -> http://localhost:8088/login/login.do?key=value
 
        //location.protocol -> http:
        //location.host -> localhost:8088 
        //location.pathname -> /login/login.do
        //location.search -> ?key=value
 
 
 
 
 
 
        //-jquery-
 
        //jQuery(location).attr('href') -> http://localhost:8088/login/login.do?key=value
        //jQuery(location).attr('protocol') -> http:
        //jQuery(location).attr('host') -> localhost:8088 
        //jQuery(location).attr('pathname') -> /login/login.do
        //jQuery(location).attr('search')-> ?key=  
    }
</script>
 
 
cs

 

감사합니다.

+ Recent posts