국정브리핑 하다가 만들어봤담..
공공기관에서는 많이 쓰이니깐 좋을듯.
<script type="text/javascript" language="JavaScript" src="http://news.go.kr/ticker/korean_news_scroll.js" ></script>
<script type="text/javascript" language="JavaScript">
<!--
document.write("<ul>");
for(i=0; i<NewsTitles.length; i++){
document.write("<li
style='margin:0;padding:0;height:2em;width:175px;text-overflow:ellipsis;
overflow:hidden;'><nobr>");
document.write(NewsTitles[i]);
document.write("<\/nobr><\/li>");
}
document.write("<\/ul>");
//-->
</script>
<script type="text/javascript">
<!--
doTickerUpper(document.getElementById("국정브리핑 div 아이디 "),2,NewsTitles.length);
//-->
</script>
function doTickerUpper(target, target_height, target_num) {
var mover = target.getElementsByTagName("ul").item(0);
// set
mover.style.position = "absolute";
mover.style.margin = "0 0 0 0";
mover.style.top = "0em";
mover.topPosition = 0;
mover.status = "true";
mover.onmouseover = function(){
this.status = "false";
}
mover.onmouseout = function(){
this.status = "true";
}
// duplicate text
mover.style.height = target_height * target_num * 2 + "em";
mover.innerHTML += mover.innerHTML;
// set action
mover.tickerAction = window.setInterval(
function()
{
if(mover.status != "false"){
if (mover.topPosition * -1 > (target_height * (target_num))) {
mover.topPosition = -0.05;
} else {
mover.topPosition -= 0.05;
}
}
mover.style.top = mover.topPosition + "em";
}
, 40);
}
------------------ 인터벌을 넣은 수정버전 --------------------------
/**
* 사용자 메인 화면 공지사항 티커 스크롤되도록 하는 함수
* @param {Object} target 스크롤 대상 객체
* @param {Object} target_height 스크롤 너비
* @param {Object} target_num 스크롤 갯수
*/
function doTickerUpper(target, target_height, target_num,move_length, interval,rest_interval) {
var mover = target.getElementsByTagName("ul").item(0);
// set
mover.style.position = "absolute";
mover.style.margin = "0 0 0 0";
mover.style.top = "0em";
mover.topPosition = 0;
mover.status = "true";
mover.moveheight = 0.0;
var interval = (typeof interval != "undefined")? interval : 40;
var rest_interval = (typeof rest_interval != "undefined")? rest_interval : 200;
mover.onmouseover = function(){
this.status = "false";
}
mover.onmouseout = function(){
this.status = "true";
}
mover.style.height = target_height * target_num * 2 + "em";
mover.innerHTML += mover.innerHTML;
// set action
mover.tickerAction = function()
{
var timer = interval;
if(mover.status != "false"){
if (mover.topPosition * -1 > (target_height * (target_num))) {
mover.topPosition = -move_length;
} else {
mover.topPosition -= move_length;
}
mover.moveheight += move_length;
if(mover.moveheight >= target_height){
timer = rest_interval;
mover.moveheight = 0.0;
}
}
mover.style.top = mover.topPosition + "em";
window.setTimeout(mover.tickerAction, timer);
}
mover.tickerAction();
}
'개인적인 프로그램 > 자바스크립트' 카테고리의 다른 글
javascript에서 with <<< 요놈 (0) | 2011.10.26 |
---|---|
개인적으로 이벤트 리스너에 등록하는 것과 이벤트의 펑션 입력시의 차이 비교 (0) | 2011.10.26 |
브라우저가 닫힐때, 새로고침을 할때, 다른사이트로 이동할때 이벤트... (0) | 2011.10.26 |
javascript 창크기 레이어크기 조절시 이벤트 (0) | 2011.10.26 |
window.onload 에 펑션을 마음대로 추가하기... (0) | 2011.10.26 |