[JS] 마우스 휠 제어

비공개 포스트라서 스크랩이 안되어, 불펌했습니다. ㅠㅠ
그런데 네이버로 검색해서 들어가면 열리는데…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* This is high-level function. */
function handle(delta) {
    var s = delta + ": ";
    if (delta < 0) s += "down";
    else s += "up";
    document.getElementById("delta").innerHTML = s;
}
 
/* Event handler for mouse wheel event. */
function wheel(event){
    var delta = 0;
    if (!event) event = window.event;
    if (event.wheelDelta) {
        delta = event.wheelDelta/120;
        if (window.opera) delta = -delta;
    } else if (event.detail) delta = -event.detail/3;
    if (delta) handle(delta);
}
 
/* Initialization code. */
if (window.addEventListener)
window.addEventListener("DOMMouseScroll", wheel, false);
window.onmousewheel = document.onmousewheel = wheel;

출처: http://cafe.naver.com/q69/64143

[JS] 오늘 하루 열지 않음

팝업창 스크립트

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!--
//*****    쿠키저장 지정시간동안 나오지 않음
function notice_setCookie( name, value, expiredays )
{
    var todayDate = new Date();
    todayDate.setTime(todayDate.getTime()+1000*60*60*12*expiredays);
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
 
//*****    쿠키저장하면서 닫기
function notice_closeWin()
{
    notice_setCookie( "aniv", "done" , 1); // 1=하룻동안 공지창 열지 않음
    top.close();
}
 
// - JavaScript - -->

메인 윈도우 스크립트

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
<!--
function notice_getCookie( name )
{
    var nameOfCookie = name + "=";
    var x = 0;
    while ( x <= document.cookie.length )
    {
        var y = (x+nameOfCookie.length);
        if ( document.cookie.substring( x, y ) == nameOfCookie ) {
            if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
            endOfCookie = document.cookie.length;
            return unescape( document.cookie.substring( y, endOfCookie ) );
        }
        x = document.cookie.indexOf( " ", x ) + 1;
        if ( x == 0 )
        break;
    }
    return "";
}
 
if ( notice_getCookie( "aniv" ) != "done" )
{
    window.open("/popups/060926.html","popups","width=450,height=700,scrollbars=no")
}
//-->

[JS] 스크롤메뉴

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var min = 350; // 레이어 top 초기 값 (레이어 top 값과 일치시킴)
var max = 0;
var moving_speed = 10  // 속도(낮을 수록 빠름)
var moving_amount = 10  // 움직임 (낮을 수록 부드러움)
var action_time = 500   // 반응시간 (*/1000 초 후에 반응)
function left_move_init() {
    itm = document.getElementById("topButton");
    //itm.set_pos = function(y){itm.style.top=y;}; 파폭에서 안됨
    itm.set_pos = function(y){itm.style.top=y+"px";};
    itm.y = min;
    itm.set_pos(itm.y);
    max = document.body.scrollHeight - itm.scrollHeight - min;
    setTimeout("left_move_func()", moving_amount);
}
function left_move_func() {
    tmp = document.body.scrollTop + min;
    itm.y += Math.floor((tmp-itm.y)/moving_speed);
    if( itm.y>max ) itm.y = max;
    if( itm.y<min ) itm.y = min;
    itm.set_pos(itm.y);
    setTimeout("left_move_func()", moving_amount);
}
setTimeout("left_move_init()", action_time);

[JS, AS3] 한글이 들어간 문자열 길이 구하기

1
2
3
function getStringLength(str){
    return(str.length+(escape(str)+"%u").match(/%u/g).length-1);
}
« Newer Posts