Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/08/2011, 04:54
miriamgomez
 
Fecha de Ingreso: abril-2008
Mensajes: 348
Antigüedad: 16 años, 1 mes
Puntos: 1
Respuesta: Scroll de Noticias

Vamos a ver, avanzamos.

Pero viene el problema grande:

Este es el codigo del script:

Código Javascript:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Untitled Document</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <style type="text/css">
  7.  
  8. /*Example CSS for the two demo scrollers*/
  9.  
  10. #pscroller1{
  11. width: 200px;
  12. height: 100px;
  13. border: 1px solid black;
  14. padding: 5px;
  15. background-color: lightyellow;
  16. }
  17.  
  18.  
  19. .someclass{ //class to apply to your scroller(s) if desired
  20. }
  21.  
  22. </style>
  23.  
  24. <script type="text/javascript">
  25.  
  26. /*Example message arrays for the two demo scrollers*/
  27.  
  28. var pausecontent=new Array()
  29. pausecontent[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!'
  30. pausecontent[1]='<a href="http://www.codingforums.com">Coding Forums</a><br />Web coding and development forums.'
  31. pausecontent[2]='<a href="http://www.cssdrive.com" target="_new">CSS Drive</a><br />Categorized CSS gallery and examples.'
  32.  
  33.  
  34. </script>
  35.  
  36. <script type="text/javascript">
  37.  
  38. /***********************************************
  39. * Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
  40. * This notice MUST stay intact for legal use
  41. * Visit http://www.dynamicdrive.com/ for this script and 100s more.
  42. ***********************************************/
  43.  
  44. function pausescroller(content, divId, divClass, delay){
  45. this.content=content //message array content
  46. this.tickerid=divId //ID of ticker div to display information
  47. this.delay=delay //Delay between msg change, in miliseconds.
  48. this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
  49. this.hiddendivpointer=1 //index of message array for hidden div
  50. document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
  51. var scrollerinstance=this
  52. if (window.addEventListener) //run onload in DOM2 browsers
  53. window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
  54. else if (window.attachEvent) //run onload in IE5.5+
  55. window.attachEvent("onload", function(){scrollerinstance.initialize()})
  56. else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
  57. setTimeout(function(){scrollerinstance.initialize()}, 500)
  58. }
  59.  
  60. // -------------------------------------------------------------------
  61. // initialize()- Initialize scroller method.
  62. // -Get div objects, set initial positions, start up down animation
  63. // -------------------------------------------------------------------
  64.  
  65. pausescroller.prototype.initialize=function(){
  66. this.tickerdiv=document.getElementById(this.tickerid)
  67. this.visiblediv=document.getElementById(this.tickerid+"1")
  68. this.hiddendiv=document.getElementById(this.tickerid+"2")
  69. this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
  70. //set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
  71. this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
  72. this.getinline(this.visiblediv, this.hiddendiv)
  73. this.hiddendiv.style.visibility="visible"
  74. var scrollerinstance=this
  75. document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
  76. document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
  77. if (window.attachEvent) //Clean up loose references in IE
  78. window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
  79. setTimeout(function(){scrollerinstance.animateup()}, this.delay)
  80. }
  81.  
  82.  
  83. // -------------------------------------------------------------------
  84. // animateup()- Move the two inner divs of the scroller up and in sync
  85. // -------------------------------------------------------------------
  86.  
  87. pausescroller.prototype.animateup=function(){
  88. var scrollerinstance=this
  89. if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
  90. this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
  91. this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
  92. setTimeout(function(){scrollerinstance.animateup()}, 50)
  93. }
  94. else{
  95. this.getinline(this.hiddendiv, this.visiblediv)
  96. this.swapdivs()
  97. setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
  98. }
  99. }
  100.  
  101. // -------------------------------------------------------------------
  102. // swapdivs()- Swap between which is the visible and which is the hidden div
  103. // -------------------------------------------------------------------
  104.  
  105. pausescroller.prototype.swapdivs=function(){
  106. var tempcontainer=this.visiblediv
  107. this.visiblediv=this.hiddendiv
  108. this.hiddendiv=tempcontainer
  109. }
  110.  
  111. pausescroller.prototype.getinline=function(div1, div2){
  112. div1.style.top=this.visibledivtop+"px"
  113. div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
  114. }
  115.  
  116. // -------------------------------------------------------------------
  117. // setmessage()- Populate the hidden div with the next message before it's visible
  118. // -------------------------------------------------------------------
  119.  
  120. pausescroller.prototype.setmessage=function(){
  121. var scrollerinstance=this
  122. if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
  123. setTimeout(function(){scrollerinstance.setmessage()}, 100)
  124. else{
  125. var i=this.hiddendivpointer
  126. var ceiling=this.content.length
  127. this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
  128. this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
  129. this.animateup()
  130. }
  131. }
  132.  
  133. pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
  134. if (tickerobj.currentStyle)
  135. return tickerobj.currentStyle["paddingTop"]
  136. else if (window.getComputedStyle) //if DOM2
  137. return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
  138. else
  139. return 0
  140. }
  141.  
  142. </script>
  143. </head>
  144.  
  145. <body>
  146. <script type="text/javascript">
  147.  
  148. //new pausescroller(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds)
  149.  
  150. new pausescroller(pausecontent, "pscroller1", "someclass", 1000)
  151.  
  152.  
  153. </script>
  154. </body>
  155. </html>


Y este es el codigo de la base de datos:
Código PHP:
Ver original
  1. <?
  2. //Conexion con la base
  3. mysql_connect( "localhost", "usuario", "contraseña");//Ejecutamos la sentencia SQL
  4. $result=mysql_db_query("base","SELECT * FROM tabla");
  5. //Mostramos los registros
  6.  
  7. echo '<Marquee Behavior="Scroll" Direction="Up" Height="140" ScrollAmount="3"
  8.  
  9. ScrollDelay="100" onMouseOver="this.stop()" onMouseOut="this.start()">';
  10. echo '<table>';
  11. while ($row=mysql_fetch_array($result))
  12. {
  13. echo"<tr>
  14. <td>".$row["titulo"]."</td>
  15. </tr>";
  16. }//fin del while
  17. echo"</table></marquee>";
  18. ?>


Pero lo siento, no se como "enlazarlos", alguna idea de como hacerlo?

Un saludo y gracias