사이트 내 전체검색
스크롤 되는 공지입니다
https://cmd.kr/javascript/245 URL이 복사되었습니다.

본문

소스는 다음과 같습니다.
ctnt의 공지내용(링크)을 수정하시고..
speed로 스크롤 속도도 조정하시고(2로 하면 더 빨리 스크롤 됩니다)..
scroll_div의 테두리 및 크기 조정하시고..
body에서 onload=startText() 하시면 됩니다..

<HTML>
<HEAD>
<script language="JavaScript">
var mouse=1;
var speed=1; // 스크롤 스피드

var ctnt // 출력될 텍스트(링크)를 수정하시면 됩니다. 형식은 처음만 빼고 ctnt += "내용";
ctnt = " · <a href=링크>스크롤 공지1</a><br />";
ctnt += " · <a href=링크>스크롤 공지2</a><br />"
ctnt += " · <a href=링크>스크롤 공지3</a><br />";
ctnt += " · <a href=링크>스크롤 공지4</a><br />";

function startText() {
scroll_first.innerHTML = ctnt;
scroll_second.innerHTML = ctnt;
document.getElementById('scroll_first').style.top = 0;
document.getElementById('scroll_second').style.top = document.getElementById('scroll_first').offsetHeight;
window.setTimeout("scroll()",100);
}
function scroll() {
if (mouse) {
first = document.getElementById('scroll_first').style;
second = document.getElementById('scroll_second').style;

if (parseInt(first.top) <= scroll_first.offsetHeight*(-1)) {
first.top = scroll_first.offsetHeight;
}
if (parseInt(second.top) <= scroll_first.offsetHeight*(-1)) {
second.top = scroll_first.offsetHeight;
}

first.top = parseInt(first.top)-speed;
second.top = parseInt(second.top)-speed;
}
window.setTimeout("scroll()",100);
}
</script>
</HEAD>

<BODY onload=startText()>

<div style="border:1 solid black; padding:3px; height: 80px; width: 201px; position: relative; overflow:hidden;" onMouseover="mouse=0" onMouseout="mouse=1" id="scroll_div">
<div id="scroll_first" style="position:absolute;top:0;"></div>
<div id="scroll_second" style="position:absolute;top:0;"></div>
</div>

</BODY>
</HTML>

출처 : http://www.aircon1004.com/data/bbs/board.php?bo_table=pds1&wr_id=57

댓글목록

등록된 댓글이 없습니다.

831 (10/17P)

Search

Copyright © Cmd 명령어 3.145.64.235