Foros del Web » Programando para Internet » Javascript »

este "slider" no me funciona

Estas en el tema de este "slider" no me funciona en el foro de Javascript en Foros del Web. este "slider" no me funciona isabel porque @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código Javascript : Ver original <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" ...
  #1 (permalink)  
Antiguo 25/11/2011, 17:12
Avatar de jor_0203  
Fecha de Ingreso: octubre-2011
Ubicación: mexico
Mensajes: 760
Antigüedad: 12 años, 6 meses
Puntos: 8
este "slider" no me funciona

este "slider" no me funciona isabel
porque


Código Javascript:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
  3. <head>
  4. <meta http-equiv="Content-Type" content="application/xhtml; charset=utf-8" />
  5. <title></title>
  6. <style type="text/css">
  7. #cont {
  8. width: 198px;
  9. height: 198px;
  10. }
  11. #capa1 {
  12. width: 198px;
  13. height: 198px;
  14. background: yellow;
  15. overflow: hidden;
  16. }
  17. #capa2 {
  18. width: 198px; /* ha de ser multiplo de 3, puesto que la "iteración" es de 3 en 3 */
  19. height: 197px;
  20. background: red;
  21. overflow: hidden;
  22. }
  23. </style>
  24. <script type="text/javascript">
  25. window.onload = function() {
  26. var contenedor = document.getElementById('cont');
  27. if(contenedor.addEventListener) {
  28. contenedor.addEventListener('mouseover', function() {
  29. creaIntervalo(document.defaultView.getComputedStyl e(document.getElementById('capa2'), null).getPropertyValue('width'), document.defaultView.getComputedStyle(document.get ElementById('capa2'), null).getPropertyValue('height'), 0)},false);
  30.  
  31. contenedor.addEventListener('mouseout', function() {
  32. creaIntervalo(document.defaultView.getComputedStyl e(document.getElementById('capa2'), null).getPropertyValue('width'), document.defaultView.getComputedStyle(document.get ElementById('capa2'), null).getPropertyValue('height'), 1)},false);
  33. } else { ie8-
  34. contenedor.attachEvent('onmouseover', function() {
  35. creaIntervalo(document.styleSheets[0].rules[2].style['width'], document.styleSheets[0].rules[2].style['height'], 0)
  36. }
  37. );
  38. contenedor.attachEvent('onmouseout', function() {
  39. creaIntervalo(document.styleSheets[0].rules[2].style['width'], document.styleSheets[0].rules[2].style['height'], 1)
  40. }
  41. );
  42. }
  43. }
  44. var intervalo;
  45. function creaIntervalo(w_bloque, h_bloque, evento) {
  46. var bloque = document.getElementById('capa2');
  47. var w_bloque = w_bloque;
  48. var h_bloque = h_bloque;
  49. if (evento == 1) {
  50. clearTimeout(intervalo);
  51. despliega(bloque, w_bloque, h_bloque);
  52. } else {
  53. clearTimeout(intervalo);
  54. repliega(bloque, w_bloque, h_bloque);
  55. }
  56. }
  57. function despliega(bloque, w, h) {
  58. var ancho = parseInt(w);
  59. var alto = parseInt(h);
  60. if (ancho <= 198) {
  61. ancho += 3;
  62. bloque.style.width = ancho + 'px';
  63. if (document.all && parseFloat(navigator.userAgent.match(/MSIE\s\d\.\d/).toString().split(' ')[1]) < 9) { // hay que cambiar las propiedades para ie8-
  64. document.styleSheets[0].rules[2].style['width'] = ancho + 'px';
  65. }
  66. intervalo = setTimeout(function(){despliega(bloque, ancho, alto)}, 8);
  67. } else if (alto <= 197) {
  68. alto += 3;
  69. bloque.style.height = alto + 'px';
  70. if (document.all && parseFloat(navigator.userAgent.match(/MSIE\s\d\.\d/).toString().split(' ')[1]) < 9) { // hay que cambiar las propiedades para ie8-
  71. document.styleSheets[0].rules[2].style['height'] = alto + 'px';
  72. }
  73. intervalo = setTimeout(function(){despliega(bloque, ancho, alto)}, 8);
  74. } else {
  75. clearTimeout(intervalo);
  76. }
  77. }
  78. function repliega(bloque, w, h) {
  79. var ancho = parseInt(w);
  80. var alto = parseInt(h);
  81. if (alto >= 30) {
  82. alto -= 3;
  83. bloque.style.height = alto + 'px';
  84. if (document.all && parseFloat(navigator.userAgent.match(/MSIE\s\d\.\d/).toString().split(' ')[1]) < 9) { // hay que cambiar las propiedades para ie8-
  85. document.styleSheets[0].rules[2].style['height'] = alto + 'px';
  86. }
  87. intervalo = setTimeout(function(){repliega(bloque, ancho, alto)}, 8);
  88. } else if (ancho >= 3) {
  89. ancho -= 3;
  90. bloque.style.width = ancho + 'px';
  91. if (document.all && parseFloat(navigator.userAgent.match(/MSIE\s\d\.\d/).toString().split(' ')[1]) < 9) { // hay que cambiar las propiedades para ie8-
  92. document.styleSheets[0].rules[2].style['width'] = ancho + 'px';
  93. }
  94. intervalo = setTimeout(function(){repliega(bloque, ancho, alto)}, 8);
  95. } else {
  96. clearTimeout(intervalo);
  97. }
  98. }
  99. </script>
  100. </head>
  101. <body>
  102. <div id="cont">
  103. <div id="capa1">
  104. <div id="capa2"></div>
  105. <br /><br /><br /><br />Este texto no lo habías visto<br /><br />
  106. </div>
  107. </div>
  108. </body>
  109. </html>
  #2 (permalink)  
Antiguo 25/11/2011, 17:36
Avatar de IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: este "slider" no me funciona

el problema está en que se han creado unos espacios
Cita:
if(contenedor.addEventListener) {
contenedor.addEventListener('mouseover', function() {
creaIntervalo(document.defaultView.getComputedStyl e(document.getElementById('capa2'), null).getPropertyValue('width'), document.defaultView.getComputedStyle(document.get ElementById('capa2'), null).getPropertyValue('height'), 0)},false);

contenedor.addEventListener('mouseout', function() {
creaIntervalo(document.defaultView.getComputedStyl e(document.getElementById('capa2'), null).getPropertyValue('width'), document.defaultView.getComputedStyle(document.get ElementById('capa2'), null).getPropertyValue('height'), 1)},false);
} else { ie8-
necesitas una consola de errores, ya!!

si persiste el problema, busca mas espacios que se hayan creado
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}
  #3 (permalink)  
Antiguo 25/11/2011, 18:39
Avatar de jor_0203  
Fecha de Ingreso: octubre-2011
Ubicación: mexico
Mensajes: 760
Antigüedad: 12 años, 6 meses
Puntos: 8
Respuesta: este "slider" no me funciona

estoy checando el código
pero estoy impresionado
este tipo de código es un ejemplo de dinamismo en javascript, aunque me asusta
véanlo
ya que les puede dar muchas ideas
ojala que con el tiempo pueda llegar a ser como isabelm

Última edición por jor_0203; 28/11/2011 a las 03:54

Etiquetas: html, slider
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:54.