Foros del Web » Programando para Internet » Javascript »

ayuda porfa,con esta funcion

Estas en el tema de ayuda porfa,con esta funcion en el foro de Javascript en Foros del Web. estoy usando asp.net, se quiere que al darle click a la imagenbutton, esta se agrande, pero que sucede, se agranda y luego regresa a posición ...
  #1 (permalink)  
Antiguo 07/08/2010, 12:57
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
ayuda porfa,con esta funcion

estoy usando asp.net, se quiere que al darle click a la imagenbutton, esta se agrande, pero que sucede, se agranda y luego regresa a posición original en 1/2 segundo. aqui la funcion

function redimensionar (accion) {
var height, width
var alto = document.getElementById("ImageButton1").height;
var ancho = document.getElementById("ImageButton1").width;
if (accion == 'sumar') {
height = parseInt(alto+30);
width = parseInt(ancho+30);
document.getElementById("ImageButton1").style.heig ht = height + "px";
document.getElementById("ImageButton1").style.widt h = width + "px";
}
else
{
height = parseInt(alto-10);
width = parseInt(ancho-10);
document.getElementById("ImageButton1").style.heig ht = height + "px";
document.getElementById("ImageButton1").style.widt h = width + "px";
}
}


le coloque return false, pero nada. please
una ayudidate hermanito
  #2 (permalink)  
Antiguo 07/08/2010, 13:45
Avatar de Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: ayuda porfa,con esta funcion

Hola

El único error que veo es este
Cita:
var alto = document.getElementById("ImageButton1").height;
var ancho = document.getElementById("ImageButton1").width;
que lo cambiaría por esto ya que no ocupa css
Cita:
var alto = document.getElementById("mesa").offsetHeight;
var ancho = document.getElementById("mesa").offsetWidth;
¿Puedes mostrar como llamas a la función?

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />
  #3 (permalink)  
Antiguo 07/08/2010, 14:30
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
Respuesta: ayuda porfa,con esta funcion

Gracias por responder, aquí como lo llamo
NO funciono el cambio

<div style="z-index: 101; left: 185px; width: 36px; position: absolute; top: 136px;
height: 31px">
<asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="redimensionar('sumar')" Height="40px" ImageUrl="~/fotos/ferrari.gif"
Width="39px" /></div>
</div>

aquí el cambio que me recomendaste
function redimensionar (accion) {
var height, width
var alto = document.getElementById("ImageButton1").offsetHeig ht;
var ancho = document.getElementById("ImageButton1").offsetWidt h;
if (accion == 'sumar') {
height = parseInt(alto+30);
width = parseInt(ancho+30);
document.getElementById("ImageButton1").style.heig ht = height + "px";
document.getElementById("ImageButton1").style.widt h = width + "px";
}
else
{
height = parseInt(alto-10);
width = parseInt(ancho-10);
document.getElementById("ImageButton1").style.heig ht = height + "px";
document.getElementById("ImageButton1").style.widt h = width + "px";
}
}
  #4 (permalink)  
Antiguo 07/08/2010, 15:55
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
Respuesta: ayuda porfa,con esta funcion

Solucionado con esto

ImageButton1.Attributes.Add("onmouseOver", "javascript:redimensionar('sumar');")
ImageButton1.Attributes.Add("onmouseOut", "javascript:redimensionar('resta');")

pero lo curioso de esto es que le coloque onclick y tambien dio el mismo problema, pero me quedo onmouseOver y onmouseOut
  #5 (permalink)  
Antiguo 07/08/2010, 19:58
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
Respuesta: ayuda porfa,con esta funcion

Cita:
Iniciado por chuchufuentes Ver Mensaje
Solucionado con esto

ImageButton1.Attributes.Add("onmouseOver", "javascript:redimensionar('sumar');")
ImageButton1.Attributes.Add("onmouseOut", "javascript:redimensionar('resta');")

pero lo curioso de esto es que le coloque onclick y tambien dio el mismo problema, pero me quedo onmouseOver y onmouseOut
Bueno no he terminado, resulta que trabajo con asp.net y tengo un datalist para mostrar las foto y pensaba que con el ejemplo que hice funcionaria, pero la funcion da error no muestra nada, please ayuuuuuda

Última edición por chuchufuentes; 07/08/2010 a las 20:50
  #6 (permalink)  
Antiguo 08/08/2010, 06:00
Avatar de Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: ayuda porfa,con esta funcion

Hola

Veamos si esto te ayuda

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />
  #7 (permalink)  
Antiguo 08/08/2010, 09:26
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
Respuesta: ayuda porfa,con esta funcion

Gracias por contestar, pero googleando, consegui esto y ahora si funciona, al menos en mi PC, no lo he colocado en la web, aqui el script

var glbInc, glbDec;

function decreaseSizeImage(image) // will get back to its normal default size
{
var id = image;
if(glbInc != null) {clearTimeout(glbInc); glbInc = null;};
if (image.height > 99)
{
image.height -= 150;
image.width -= 150;
glbDec = setTimeout("decreaseSizeImage("+image+")", 32);
};
}

function increaseSizeImage(image)
{
var id = image;

if(glbDec != null) {clearTimeout(glbDec); glbDec = null;};
if (image.height < 101)
{
image.height += 150;
image.width += 150;
glbInc = setTimeout("increaseSizeImage("+image+")", 32);
};
}


aqui la imagen html asp.net

<td style="width: 117px; height: 32px">
<img src='<%#Eval("fotoparte") %>' width="104px" height="100px" alt="No Hay Imagen Disponible" id="Image2" onmouseover="increaseSizeImage(this);" onmouseout="decreaseSizeImage(this);" />
</td>

muchaaaaas gracias
  #8 (permalink)  
Antiguo 08/08/2010, 09:49
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
Respuesta: ayuda porfa,con esta funcion

Otra forma de solucionarlo y mucho menos código usando CSS

<td style="width: 117px; height: 32px">
<img src='<%#Eval("fotoparte") %>' width="104px" height="100px" alt="No Hay Imagen Disponible" id="Image2"" />
</td>

CSS

<style type="text/css">

img:hover{ width:300px; height:300px;}
</style>

Etiquetas: funcion
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 01:40.