Ir para conteúdo
Fórum Script Brasil
  • 0

Scroll Na Div


Andreia Regina

Pergunta

Oi!

Estou com dificuldade em fazer o seguinte script funcionar no Firefox, Opera e Netscape, no IE funciona certinho e deveria funcionar nos outros pois testei o script antes de alterar na minha página, segue:

parte css:

#aniversariantes {
position: absolute;
overflow: hidden;
botton: 330px;
right: 5px;
background-color: #FFFFE8;
width:95%;
height: 260px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight:bold;
color:#000;
padding-left:5px}

#Scroller-1 {
position: absolute;
overflow: hidden;
botton: 330px;
right: 5px;
width: 90%;
height: 260px}

#Scroller-1 p {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight:bold;
color:#000}

.Scroller-Container {
position: absolute;
top: 0px;
right: 0px;}

.Scrollbar-Up {
cursor: pointer;
position: absolute;
top: 10px;
right: 5px}

.Scrollbar-Down {
cursor: pointer;
position: absolute;
top: 215px;
right: 5px}
javascript no arquivo index
<script type="text/javascript" src="jsScroller.js"></script>

<script language="JavaScript">
<!--
var scroller = null;
window.onload = function () {
 var el = document.getElementById("Scroller-1");
 scroller = new jsScroller(el, 400, 200);
}
//-->
</script>
html:
      <div id=aniversariantes>
 <img src="imagens/seta_up.gif" alt="Subir" class="Scrollbar-Up" onmouseover="scroller.startScroll(0, 5);" onmouseout="scroller.stopScroll();" />
 <img src="imagens/seta_down.gif" alt="Descer" class="Scrollbar-Down" onmouseover="scroller.startScroll(0, -5);" onmouseout="scroller.stopScroll();" />      
 <div id="Scroller-1">
 <div class="Scroller-Container">
     <p align="center" class="anivers"> <strong>Feliz Aniversário:<br /></strong></p>
     Nome dos aniversariantes vindo do bd
    </div>
    <!-- Scroller-1 -->
  </div>
     <!-- Scroller-Container -->
     </div>
     <!-- aniversariantes -->
Arquivo javascript com a função toda:
//Written by Nathan Faubion: http://n-son.com
//Use this or edit how you want, just give me
//some credit!

function jsScroller (o, w, h) {
var self = this;
var list = o.getElementsByTagName("div");
for (var i = 0; i < list.length; i++) {
 if (list[i].className.indexOf("Scroller-Container") > -1) {
  o = list[i];
 }
}

//Private methods
this._setPos = function (x, y) {
 if (x < this.viewableWidth - this.totalWidth)
  x = this.viewableWidth - this.totalWidth;
 if (x > 0) x = 0;
 if (y < this.viewableHeight - this.totalHeight)
  y = this.viewableHeight - this.totalHeight;
 if (y > 0) y = 0;
 this._x = x;
 this._y = y;
 with (o.style) {
  left = this._x +"px";
  top  = this._y +"px";
 }
};

//Public Methods
this.reset = function () {
 this.content = o;
 this.totalHeight = o.offsetHeight;
 this.totalWidth  = o.offsetWidth;
 this._x = 0;
 this._y = 0;
 with (o.style) {
  left = "0px";
  top  = "0px";
 }
};
this.scrollBy = function (x, y) {
 this._setPos(this._x + x, this._y + y);
};
this.scrollTo = function (x, y) {
 this._setPos(-x, -y);
};
this.stopScroll = function () {
 if (this.scrollTimer) window.clearInterval(this.scrollTimer);
};
this.startScroll = function (x, y) {
 this.stopScroll();
 this.scrollTimer = window.setInterval(
  function(){ self.scrollBy(x, y); }, 40
 );
};
this.swapContent = function (c, w, h) {
 o = c;
 var list = o.getElementsByTagName("div");
 for (var i = 0; i < list.length; i++) {
  if (list[i].className.indexOf("Scroller-Container") > -1) {
   o = list[i];
  }
 }
 if (w) this.viewableWidth  = w;
 if (h) this.viewableHeight = h;
 this.reset();
};

//variables
this.content = o;
this.viewableWidth  = w;
this.viewableHeight = h;
this.totalWidth  = o.offsetWidth;
this.totalHeight = o.offsetHeight;
this.scrollTimer = null;
this.reset();
};

Mais informações: acesse aqui

Desde já agradeço

Andreia Regina

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

POde só ter sido erro de digitaçao seu na hora de postar mas no html o primero div com id aniversariante esta sem as aspas...não sei se isso altera só achei curioso porque ele é o unio sem...

falou...

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,7k
×
×
  • Criar Novo...