위로 스크롤 되는 배너

렛츠웹 + 게임/My Tip 2009. 1. 5. 16:56

<!---------------------main_top_text_header.js------------------->

var topTextBanners = [['http://www.gmarket.co.kr/challenge/neo_sangsul/plan_display.asp?sid=32387&pos_shop_cd=EC&pos_class_cd=900000006&pos_class_kind=T','아이비&황보가 떴다!->','ico_event.gif']
,['http://www.gmarket.co.kr/challenge/neo_sangsul/plan_display.asp?sid=29571&pos_class_cd=900000011&pos_class_kind=T','[1+1]아동구두 7,500원!','ico_sale.gif']
,['http://www.gmarket.co.kr/challenge/neo_sangsul/plan_display.asp?sid=32401&pos_class_cd=900000011&pos_class_kind=T','원하시면 만들어드립니다!','ico_special.gif']
,['http://event.gmarket.co.kr/html/200704/070407_hanacard/070407_hanacard.asp?pos_shop_cd=EC&pos_class_cd=900000013&pos_class_kind=T','무료배송체험현장go->','ico_best.gif']
,['http://www.gmarket.co.kr/challenge/neo_category/large_category_gen_100000048.asp?pos_shop_cd=EC&pos_class_cd=900000014&pos_class_kind=T','G-온라인미용실OPEN','ico_hot.gif']
,];

var iScrollerHeight = 20;  // 스크롤러의 세로
var iTotalArea = 0;
var bWait = true;
var bMouseOver = false;
var iScrollSpeed = 1;   // Scrolling 속도
var iWaitTime = 4000;   // 멈추는 시간
var iTemp = 0;
var iMovingAmount = 20;
var arrScrollContent = new Array();
var i;

function startscroll()    // 스크롤 시작
{
 for (i = 0; i < arrScrollContent.length; i++)
 {
  insert_area(iTotalArea, iTotalArea++); // area 삽입
 }
 
 window.setTimeout("scrolling()", iWaitTime);
}

function scrolling()    // 실제로 스크롤 하는 부분
{
 if (!bMouseOver && bWait)
 {
  for (i = 0; i < iTotalArea; i++)
  {
   tmp = document.getElementById('scroll_area' + i).style;
   tmp.top = parseInt(tmp.top) - iScrollSpeed;

   if (parseInt(tmp.top) <= -iScrollerHeight)
   {
    tmp.top = iScrollerHeight * (iTotalArea - 1);
   }

   if (iTemp++ == ((iMovingAmount - 1) * arrScrollContent.length + 1))
   {
    bWait = false;
    window.setTimeout("bWait=true; iTemp=0;", iWaitTime);
   }
  }
 }

 window.setTimeout("scrolling()", 0);
}

function next_scrolling()    // 실제로 스크롤 하는 부분
{
 for (i = 0; i < iTotalArea; i++)
 {
  tmp = document.getElementById('scroll_area' + i).style;
  tmp.top = parseInt(tmp.top) - iScrollerHeight;

  if (parseInt(tmp.top) <= -iScrollerHeight)
  {
   tmp.top = iScrollerHeight * (iTotalArea - 1);
  }
 }
}

function insert_area(idx, n)
{
 var strContent
 strContent = '<div style="left: 0px; width: 179px; height: 20px; position: absolute; top: ' + (iScrollerHeight * n) + 'px" id="scroll_area' + n + '">';
 strContent += arrScrollContent[idx];
 strContent += '</div>';
 document.write(strContent);
}

function checkMouseOver()
{
 var count
 
 count = 0
 for (i = 0; i < iTotalArea; i++)
 {
  tmp = document.getElementById('scroll_area' + i).style;
  
  if (parseInt(tmp.top) % iScrollerHeight != 0)
   count++;
 }
 
 if(count == 0)
  bMouseOver = true;
}

for(i=0; i<5; i++)
{
 arrScrollContent[i] = "<table cellSpacing='0' cellPadding='0' width='100%' border='0'><tr><td width='39' align='center'><img src='http://image.gmarket.co.kr/challenge/neo_image/newmain5/" + topTextBanners[i][2] + "' width='35' height='11'></td><td width='140' class='texttopAD'><font color='#000000'><a href='" + topTextBanners[i][0] + "'>" + topTextBanners[i][1] + "</a></font></td></tr></table>";
}
<!-- Be Generated Successfully -->
<!--2007-04-12 19:10:00-->

<!---------------------main_top_text_header.js------------------->

<!---------------------실행------------------->

<script src=main_top_text_header.js></script>

<span style="left:0px;width:225px;position:relative;height:195px;top:3px">
 <div style="left:0px;width:225px;clip: rect(0px 225px 195px 0px);position:absolute;top:0px;height:195px" onMouseover="javascript:checkMouseOver();" onMouseout="bMouseOver=false;">
  <script language="javascript">startscroll();</script>
 </div>
</span>


posted by 망차니

설정

트랙백

댓글