| Ver tema anterior :: Ver siguiente tema |
| Autor |
Mensaje |
Gonzalo Orellana Conociendo Foroz

Registrado: 23 Mar 2008
Mensajes: 12
|
Publicado: Mie Abr 30, 2008 9:37 am Título del mensaje: Problema con javascript |
|
|
Hola, tengo un pequeño problema con javascript. Se supone que quiero que aparezca una imagen y que al pulsar los botones cambie el tamaño de ésta. Esto es lo que tengo, pero no sé en qué falla. A ver si podeis ayudarme.
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Imagen botones</title>
<script language="JavaScript">
function grande() {
alert("Tamaño grande");
getElementById(imagen).height=640px;
getElementById(imagen).width=480px;
return;
}
</script>
<script language="JavaScript">
function medio() {
alert("Tamaño medio");
getElementById(imagen).height=320px;
getElementById(imagen).width=240px;
return;
}
</script>
<script language="JavaScript">
function pequeño() {
alert("¡Tamaño pequeño!");
getElementById(imagen).height=160px;
getElementById(imagen).width=120px;
return;
}
</script>
</head>
<body>
<div style="text-align: center;"><big><span
style="font-weight: bold;">TITULO<br>
<br>
</span></big></div>
<div style="text-align: center;"><img id="imagen"
style="width: 320px; height: 240px;" alt="Imagen"
src="http://www.portalpirata.com/imgs/windows-vista-logo-1.jpg">
<br>
</div>
<br>
<form> <input name="grande" value="Grande"
onclick="grande()" type="button"></form>
<br>
<form> <input name="mediano" value="Mediano"
onclick="medio()" type="button"></form>
<br>
<form><input name="pequeño" value="Pequeñajo"
onclick="pequeño()" type="button"></form>
</body>
</html> |
|
| Volver arriba |
|
 |
lnxmen User destacando


Registrado: 10 Ene 2007
Mensajes: 287
Ubicación: Alcalá de Henares, Madrid, España
|
Publicado: Mie Abr 30, 2008 11:24 am Título del mensaje: |
|
|
Creo que este post iria mejor en la zona de Programación.
Pero creo que deberias dejar el codigo de esta manera:
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Imagen botones</title>
<script language="JavaScript">
function grande() {
alert("Tamaño grande");
getElementById(imagen).height=640px;
getElementById(imagen).width=480px;
return;
}
function medio() {
alert("Tamaño medio");
getElementById(imagen).height=320px;
getElementById(imagen).width=240px;
return;
}
function pequeño() {
alert("¡Tamaño pequeño!");
getElementById(imagen).height=160px;
getElementById(imagen).width=120px;
return;
}
</script>
</head>
<body>
<div style="text-align: center;"><big><span
style="font-weight: bold;">TITULO<br>
<br>
</span></big></div>
<div style="text-align: center;"><img id="imagen"
style="width: 320px; height: 240px;" alt="Imagen"
src="http://www.portalpirata.com/imgs/windows-vista-logo-1.jpg">
<br>
</div>
<br>
<form> <input name="grande" value="Grande"
onclick="grande()" type="button"></form>
<br>
<form> <input name="mediano" value="Mediano"
onclick="medio()" type="button"></form>
<br>
<form><input name="pequeño" value="Pequeñajo"
onclick="pequeño()" type="button"></form>
</body>
</html>
Si no te funciona abrelo con Firefox y mira la consola de error(herramientas/consola de error) y veras que te dice que grande, medio y puequeñajo no es una funcion y que además está esperando un ; en algún sitio del código. _________________ Quis custodiet ipsos custodes? |
|
| Volver arriba |
|
 |
Gonzalo Orellana Conociendo Foroz

Registrado: 23 Mar 2008
Mensajes: 12
|
Publicado: Mie Abr 30, 2008 4:31 pm Título del mensaje: |
|
|
Nada, no lo consigo. He copiado el código que me has puesto y nada. Además, he estado otra hora intentando ver qué es lo que fallaba o mirando la consola de error, pero no veo el problema  |
|
| Volver arriba |
|
 |
|
|
|