Foros del Web » Programando para Internet » Javascript »

Redimensionar imagen con javascript(ASP)

Estas en el tema de Redimensionar imagen con javascript(ASP) en el foro de Javascript en Foros del Web. Tengo una imagen que recibo mediante una BD utilizando ASP. El problema es que tengo la funcion...pero no se como llamarla... Si esta bien hecha...y ...
  #1 (permalink)  
Antiguo 05/05/2011, 01:02
 
Fecha de Ingreso: diciembre-2010
Ubicación: Alicante
Mensajes: 74
Antigüedad: 13 años, 3 meses
Puntos: 3
Redimensionar imagen con javascript(ASP)

Tengo una imagen que recibo mediante una BD utilizando ASP.
El problema es que tengo la funcion...pero no se como llamarla... Si esta bien hecha...y si al no estar la funcion script dentro de el do while de ASP... recibira las distitnas imagenes del do while...

Funcion Javascrip:
Código:
<script language="javascript">
var red;
red=setTimeout('imag()',0);

function imag()
{
var nombre=<% rs("foto")%>
var img=new Image();
img.src="http://www.luqentia.es/fotos/"+nombre;
if (img.width>500)
{
<%
response.write "<br> <img style='padding-left:40px' src='http://www.luqentia.es/fotos/"& rs("foto") &"' width='500px'><br><br>"
%>
}
else
{
<%
response.write "<br> <img style='padding-left:40px' src='http://www.luqentia.es/fotos/"& rs("foto") &"' ><br><br>"
%>
}

}
Entonces el problema viene que no se como llamar dentro de el do while...de ASP a esa funcion... pasa cada imagen...HELP!
  #2 (permalink)  
Antiguo 10/05/2011, 02:12
 
Fecha de Ingreso: diciembre-2010
Ubicación: Alicante
Mensajes: 74
Antigüedad: 13 años, 3 meses
Puntos: 3
Respuesta: Redimensionar imagen con javascript(ASP)

he conseguido crear una funcion para mi caso... Os hago un copy paste....
Código HTML:
<%
'NOS MOVEMOS AL PRINCIPIO Y VOLVEMOS A CALCULAR LAS NOTICIAS POR PÁGINA.

	rs.MoveFirst
	rs.PageSize=not_por_pagina
	numpaginas=rs.PageCount
	rs.AbsolutePage= pagina


i=0

'EN CASO QUE ESTEMOS EN UNA PÁGINA ID SOLO MOSTRAMOS ESTÁ'
if not isEmpty(Request.QueryString("id")) then
%>
	var ids;
	ids="<% response.Write(rs("foto"))%>";
	img=document.getElementById(ids);
	if(img.width>500)
		img.width=500;
<%
'SI NO HEMOS LLEGADO AL FINAL DE LA BASE DE DATOS SEGUIMOS RECOGIENDO
NUM NOTICIAS ES UN CONTADOR QUE SE INCREMENTA ANTERIORMENETE PARA SABER EL NUMERO DE NOTICIAS DE CADA PAGINA.'
else
		if not rs.eof then
		%>
		var ids=new Array(<%=num_noticias%>);
			var j;
		<%
		else
	
		%>
		var ids=new Array(<%=num_noticias%>);
			var j;
			<%
		end if
		%>
	<!--CREAMOS EL ARRAY-->
	
	<%
	
	do while i<num_noticias
			%>
			ids[<%response.Write(i)%>]="<% response.Write(rs("foto"))%>";
			<%
			i=i+1 
		rs.MoveNext
	loop

	%>
<!--REDIMENSIONAMOS GRACIAS A ESTE FOR-->
for (j=0;j<ids.length;j++)
{
	if(ids[j]!="")
	{ 
	
	img=document.getElementById(ids[j]);
	if (img.width>500)
		img.width=500;
	}
}
<%
end if 
%>
}
</script> 
  #3 (permalink)  
Antiguo 10/05/2011, 05:30
Avatar de IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Redimensionar imagen con javascript(ASP)

en lugar de usar la propiedad image width, yo usaría la propiedad style object width por que te permite usar unidades

Etiquetas: redimensionar
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 10:26.