JavaScript - Código switch no carga enlaces

   
Vista:

Código switch no carga enlaces

Publicado por Cristian (1 intervención) el 29/06/2016 21:47:59
Hola,

Tengo un código que cambia imágenes según día y hora, pero yo quiero que pueda insertar enlaces en las imágenes, he intentado con el código normal e incluso reemplazando el código <img src=... del principio pero no funciona. dejo un fragmento del código para que puedan ayudarme.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<script type="text/javascript">
//<![CDATA[
 
day = new Date()
hr = day.getHours()
dia = day.getDay()
switch(dia){
 
<!--CASE 1 LUNES  -->
 
case 1:
 
<!-- Programación de este día

document.write("<img src='")

if (hr == 1) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 2) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 3) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 4) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 5) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 6) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 7) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 8) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 9) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 10) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 11) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 12) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 13) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 14) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 15) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 16) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png")
if (hr == 17) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i48dbefc1e8fb5562/version/1467173042/image.png")
if (hr == 18) document.write("https://image.jimcdn.com/app/cms/image/transf/dimension=989x10000:format=png/path/s6b081c57b76a6f53/image/i0b044c7e9f3d7a46/version/1467173061/image.png")
if (hr == 19) document.write("https://image.jimcdn.com/app/cms/image/transf/dimension=989x10000:format=png/path/s6b081c57b76a6f53/image/i0b044c7e9f3d7a46/version/1467173061/image.png")
if (hr == 20) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/icf193db9057942bb/version/1467168815/image.png")
if (hr == 21) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/icf193db9057942bb/version/1467168815/image.png")
if (hr == 22) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/icf193db9057942bb/version/1467168815/image.png")
if (hr == 23) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/icf193db9057942bb/version/1467168815/image.png")
if (hr == 0) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/icf193db9057942bb/version/1467168815/image.png")
document.write("'>")

// fin -->

break;      }
//]]>
</script>

Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve

Código switch no carga enlaces

Publicado por xve (1595 intervenciones) el 30/06/2016 07:31:10
Hola Cristian, segun entiendo seria algo así:

1
2
3
4
5
6
document.write("<a href='http://www.lawebdelprogramador.com'><img src='");
 
if (hr == 1) document.write("https://image.jimcdn.com/app/cms/image/transf/none/path/s6b081c57b76a6f53/image/i64152b43622db3cf/version/1467168082/image.png");
...
 
document.write("'></a>");

Coméntanos, ok?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar