본문 바로가기

javascript

텍스트 배너 뒤집기

<!--1. 아래의 스크립트를 <HEAD></HEAD>사이에 복사해 넣으세요-->

<script>

<!-- Beginning of JavaScript -

// CREDITS:
// TextTopper by Urs Dudli and Peter Gehrig
// Copyright (c) 2000 Peter Gehrig and Urs Dudli. All rights reserved.

var message = new Array()
message[0]="HI MASTER OF CYBERSPACE!"
message[1]="SUNNY DAY TODAY?"
message[2]="THEN TURN OFF YOUR PC."
message[3]="AND TAKE A STROLL."
message[4]="OR HIM."

// 메세지 박스의 크기
var scrollerheight=200
var scrollerwidth=800

// 글꼴
var font_family="Verdana"

// 글자크기
var font_size=50

// 스크롤러의 위치
var x_textposition=10
var y_textposition=10

// 여기까지,


var i_message=0
var i_loop=0
var max_loop=45
var timer
scrollerwidth=2*scrollerwidth
y_textposition=y_textposition-scrollerheight+font_size
x_textposition=x_textposition-Math.floor(scrollerwidth/2)


function initiate() {
        if (document.all) {                
                document.all.rotationstyle.style.posLeft=x_textposition
                document.all.rotationstyle.style.posTop=y_textposition
        changemessage()
        }
}

function changemessage() {
                do_rotate="yes"
                rotationstyle.innerHTML=
                '<OBJECT ID="rotationobj" CLASSID="CLSID:369303C2-D7AC-11d0-89D5-00A0C90833E6" STYLE="position:relative;width:'+scrollerwidth+'px;height:'+2*scrollerheight+'px">'+
        '<PARAM NAME="Line0001" VALUE="SetLineStyle(0)">'+
        '<PARAM NAME="Line0002" VALUE="SetLineColor(255,255,255)">'+
                '<PARAM NAME="Line0003" VALUE="SetFillColor(0,0,255)">'+
                '<PARAM NAME="Line0004" VALUE="SetFont(\''+font_family+'\', '+font_size+', 400, 0, 0, 0)">'+
                '<PARAM NAME="Line0005" VALUE="Text(\''+message[i_message]+'\',0, 2, 0)">'+
                '</OBJECT>'                
                rotationobj.Rotate(-90,0,0)
                startscroll()
                
}

function startscroll() {
        if (i_loop < max_loop) {
        rotationobj.Rotate(2,0,0)

                i_loop++
                timer=setTimeout("startscroll()",20)
        }
   else {
                i_loop=0
                timer=setTimeout("endscroll()",2000)
        }
}

function endscroll() {
        if (i_loop < max_loop) {
        rotationobj.Rotate(-2,0,0)

                i_loop++
                timer=setTimeout("endscroll()",50)
        }
   else {
        i_message++
                i_loop=0
        if (i_message>=message.length) {i_message=0}
                timer=setTimeout("changemessage()",1000)
        }
}

// - End of JavaScript - -->
</script>
</HEAD>

<!--2. <BODY> 태그내에 onload="" 혹은 onunload 부분이 있으면 복사해 넣으세요-->

<BODY BGCOLOR="#FFFFFF" onLoad="initiate()">

<!--3. <BODY></BODY> 부분에 아래의 스크립트를 복사해 넣으세요-->

<SPAN ID="rotationstyle" STYLE="position:absolute">
<OBJECT ID="rotationobj" CLASSID="CLSID:369303C2-D7AC-11d0-89D5-00A0C90833E6">
</OBJECT>
</SPAN>