A

간단한 텍스트 스크롤

· 17년 전 · 1458
사용상 변경의 여지는 충분히 있습니다..
소스가 간단하니.. 크게 설명은 필요없을듯 하네요.

---------------x8 cut here ---------------------------------------
<html>
<head>
<style type="text/css">
a {text-decoration:none;}
div {font-size:9pt;}
div.board_cls {
    border: 1px solid gray;
    /* text-align: center; */
    overflow: hidden; /* 이 부분을 주석처리해서 흐름을 본다 */
}
div.sign_cls {
    border: 0px solid red;
    padding-left:10px;
}
</style>

<script type="text/javascript">
<!--
var timerID = {} ;
var arrIdx = 0;
var msgs = [
            ["http://www.wikipedia.org", "_blank", "wikipedia 가기"],
            ["http://www.netcraft.com/", "_blank", "netcraft 가기"],
            ["http://www.python.org", "_blank", "python 가기"],
            ["http://www.php.net", "_blank", "php 가기"],
            ["http://www.eidf.org", "_blank", "eidf 가기"],
            ["", "", "그냥 텍스트"]
          ];


function makeSign(arr) {
    if (arr.length) {
        if (arr[0] != "") {
            return "<a href='"+ arr[0] +"' target='"+ arr[1] +"'>"+ arr[2] +"</a>";
        }
        else {
            return arr[2];
        }
    }
}

//board 껍데기
function initBoard(boardID, posX, posY) {
    var board = document.getElementById(boardID);
    var bstyle = board.style;

    // sign position
    bstyle.position="absolute";
    bstyle.top = posY; // "150px";
    bstyle.left = posX ; //"150px";

    // sign size
    bstyle.height = "15pt";
    bstyle.width = "200pt";
}

// text (높이값을 적당히 셋팅해야 한다. 아래 줄이 짤리지 않게.)
function initSign(signID, boardID) {
    var board = document.getElementById(boardID);
    var sign = document.getElementById(signID);

    sstyle = sign.style;
    sstyle.position = "relative";
    sstyle.top = parseInt(board.style.height) ;

    sstyle.width = board.style.width;
    sstyle.height = board.style.height;
}


function upwardSign(boardID, signID) {
    var board = document.getElementById(boardID);
    var sign = document.getElementById(signID);

    sign.style.top = parseInt(sign.style.top) - 1; // 이동 범위 -픽셀(이것을 2이상으로 할 경우 머무는 자리의 숫자에 영향

    if (parseInt(sign.style.top) * -1 > parseInt(sign.style.height)) {
        arrIdx = arrIdx + 1;
        initSign(signID, boardID);
        sign.innerHTML = makeSign(msgs[arrIdx%msgs.length]);
    }

    if (parseInt(sign.style.top) == 3) { // 상단에서 숫자만큼의 픽셀 아래에 머물다.
        clearTimeout(timerID[boardID]);
        timerID[boardID] = setTimeout("upwardSign('"+ boardID + "', '"+ signID +"')", 1000); // 1초간 머뭄
        //timerID[boardID] = setTimeout("upwardSign('"+ boardID + "', '"+ signID +"')", 1000 + (Math.random() * 1000)); // 1 - 2초간 머뭄
    }
    else {
        timerID[boardID] = setTimeout("upwardSign('"+ boardID + "', '"+ signID +"')", 50); // 이동 속도 (0.05초)
    }
}


function scroll(boardID, signID, posX, posY) {
    var board = document.getElementById(boardID);
    var sign = document.getElementById(signID);
   
    initBoard(boardID, posX, posY);
    initSign(signID, boardID);
    sign.innerHTML = makeSign(msgs[arrIdx%msgs.length]);
    upwardSign(boardID, signID);
}
//-->
</script>
</head>
<body onload="scroll('board', 'sign', 50, 100); scroll('board2', 'sign2', 50, 125); scroll('board3', 'sign3', 50, 150);">

현재는 메세지를 공유하기 때문에 하나씩 건너서 보여진다.<br />

<div class="board_cls" id="board">
    <div class="sign_cls" id="sign" onMouseOver="clearTimeout(timerID['board'])" onMouseOut="upwardSign('board', 'sign')">11</div>
</div>
<div class="board_cls" id="board2">
    <div class="sign_cls" id="sign2" onMouseOver="clearTimeout(timerID['board2'])" onMouseOut="upwardSign('board2', 'sign2')">22</div>
</div>
<div class="board_cls" id="board3">
    <div class="sign_cls" id="sign3" onMouseOver="clearTimeout(timerID['board3'])" onMouseOut="upwardSign('board3', 'sign3')">33</div>
</div>

</body>
</html>
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

프로그램

+
제목 글쓴이 날짜 조회
17년 전 조회 1,706
17년 전 조회 2,241
17년 전 조회 1,547
17년 전 조회 1,719
17년 전 조회 2,713
17년 전 조회 2,136
17년 전 조회 1,791
17년 전 조회 4,194
17년 전 조회 3,041
17년 전 조회 1,433
17년 전 조회 3,565
17년 전 조회 2,796
17년 전 조회 2,076
17년 전 조회 1,292
17년 전 조회 2,326
17년 전 조회 2,065
17년 전 조회 1,977
17년 전 조회 1,921
17년 전 조회 1,171
17년 전 조회 1,875
17년 전 조회 2,929
17년 전 조회 1,431
17년 전 조회 1,671
17년 전 조회 1,352
17년 전 조회 1,600
17년 전 조회 1,572
17년 전 조회 1,445
17년 전 조회 2,559
17년 전 조회 2,323
17년 전 조회 2,103
17년 전 조회 1,412
17년 전 조회 2,426
17년 전 조회 4,249
17년 전 조회 2,737
17년 전 조회 1,658
17년 전 조회 1,852
17년 전 조회 3,229
17년 전 조회 2,231
17년 전 조회 3,824
17년 전 조회 1,673
17년 전 조회 2,270
17년 전 조회 2,098
17년 전 조회 1,614
17년 전 조회 2,130
17년 전 조회 1,926
17년 전 조회 1,961
17년 전 조회 3,073
17년 전 조회 2,147
17년 전 조회 1,436
17년 전 조회 1,459
17년 전 조회 2,125
17년 전 조회 3,201
17년 전 조회 2,137
17년 전 조회 1,529
17년 전 조회 4,236
17년 전 조회 2,025
17년 전 조회 3,457
17년 전 조회 6,031
17년 전 조회 1,484
17년 전 조회 1,653
17년 전 조회 1,235
17년 전 조회 1,345
17년 전 조회 2,870
17년 전 조회 1,906
17년 전 조회 2,591
17년 전 조회 1,300
17년 전 조회 3,178
17년 전 조회 2,160
17년 전 조회 2,601
17년 전 조회 1,404
17년 전 조회 1,754
17년 전 조회 1,149
17년 전 조회 1,205
17년 전 조회 1,777
17년 전 조회 1,223
17년 전 조회 4,304
17년 전 조회 1,500
17년 전 조회 2,002
17년 전 조회 7,089
17년 전 조회 1,378
17년 전 조회 1,895
17년 전 조회 3,125
17년 전 조회 1,223
17년 전 조회 1,982
17년 전 조회 1,154
17년 전 조회 1,851
17년 전 조회 2,150
17년 전 조회 2,961
17년 전 조회 1,239
17년 전 조회 1,329
17년 전 조회 1,555
17년 전 조회 1,223
17년 전 조회 4,355
17년 전 조회 3,898
17년 전 조회 2,785
17년 전 조회 1,589
17년 전 조회 1,334
17년 전 조회 1,602
17년 전 조회 2,518
17년 전 조회 1,733
🐛 버그신고