국정브리핑 하다가 만들어봤담..

 

공공기관에서는 많이 쓰이니깐 좋을듯.

 

<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";
 }

    // duplicate text
    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();
   
}
Posted by 삽지리
,