Foros del Web » Programando para Internet » Javascript »

pop up ajustado a imagen

Estas en el tema de pop up ajustado a imagen en el foro de Javascript en Foros del Web. Hola amigos, tengo una galeria de fotos en un pop up basada en el visor de tunait, el codigo funciona bien, pero me gustaria que ...
  #1 (permalink)  
Antiguo 10/10/2005, 12:15
 
Fecha de Ingreso: abril-2005
Mensajes: 169
Antigüedad: 19 años, 1 mes
Puntos: 0
pop up ajustado a imagen

Hola amigos, tengo una galeria de fotos en un pop up basada en el visor de tunait, el codigo funciona bien, pero me gustaria que el pop up se ajustara al tamaño de la imagen... me podrian ayudar.... el codigo que tengo es este:

en el index:

<script language="JavaScript">
function ventanaSecundaria (URL){
window.open(URL,"ventana1","width=500, height=350, scrollbars=no, menubar=no, location=no, resizable=no")
}
</script>

el boton:

<a href="javascript:ventanaSecundaria ('01new/visor.htm')">

y en la galeria que es el pop up:

<script type='text/JavaScript' src='fotos.js'> </script>
<script>
var afoto = new Array()
var idx=0
function inicio()
{
for (a=0;a<fotos.length;a++)
{
afoto[a] = new Image()
afoto[a].src = fotos[a]
}
muestra()
}

function pasa(dir)
{
if (dir=="i")
{
idx--
if (idx < 0) idx = afoto.length - 1
}
else
{
idx++
if (idx == afoto.length) idx = 0
}
muestra()
}

function muestra()
{
document.images["fotico"].src = afoto[idx].src
document.forms[0].leyenda.value = "Foto " + (idx+1) + " de " + afoto.length
}
</script>
<body onload="inicio()">
<form>
<input type="button" value="anterior" onclick="pasa('i')">
<input type="button" value="siguiente" onclick="pasa('d')">
</form>
<img id="fotico">
</body>


alguna idea please¿?

muchas gracias
  #2 (permalink)  
Antiguo 10/10/2005, 12:39
Avatar de Vaalegk  
Fecha de Ingreso: abril-2005
Mensajes: 154
Antigüedad: 19 años
Puntos: 2
agrega algo asi al final de tu funcion inicio:

var wp=document.all?document.all.fotico:document.getEl ementById('fotico');
if(wp){
window.resizeTo(wp.offsetWidth,wp.offsetHeight+30) ;
//juega con estos valores un poco.
}

ademas agreagale a tu body style="margin:0;"
  #3 (permalink)  
Antiguo 11/10/2005, 08:44
 
Fecha de Ingreso: abril-2005
Mensajes: 169
Antigüedad: 19 años, 1 mes
Puntos: 0
Hola Vaalegk muchas gracias por responder, pero peque lo que me dijiste al final de pop up nada...ya ni pillaba las imagenes...alguien sabe como podria hacer esto? gracias....

G
  #4 (permalink)  
Antiguo 11/10/2005, 08:50
Avatar de pinchoso  
Fecha de Ingreso: octubre-2005
Ubicación: Barcelona
Mensajes: 177
Antigüedad: 18 años, 6 meses
Puntos: 0
Hola luzin, utilizando el siguiente script puedes reescalar el tamaño de la ventana e igualarlo al de la imagen que se cargue dentro:

<SCRIPT LANGUAGE="JavaScript">
<!--
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers[0].document.images[0].width;
window.innerHeight = document.layers[0].document.images[0].height;
}
if (isIE4) {
window.resizeTo(500, 500);
width = 500 - (document.body.clientWidth - document.images[0].width);
height = 500 - (document.body.clientHeight - document.images[0].height);
window.resizeTo(width, height);
}
}
// -->
</script>

-----en el body pones----

<BODY onLoad="fitWindowSize()">

con eso deberia ser suficiente!

Saludos!
  #5 (permalink)  
Antiguo 11/10/2005, 08:58
 
Fecha de Ingreso: abril-2005
Mensajes: 169
Antigüedad: 19 años, 1 mes
Puntos: 0
Hola Pinchoso muchas gracias por responder y con tanta brevedad, pegue tu codigo tal que asi quedo....

<script type='text/JavaScript' src='fotos.js'> </script>
<script>
var afoto = new Array()
var idx=0
function inicio()
{
for (a=0;a<fotos.length;a++)
{
afoto[a] = new Image()
afoto[a].src = fotos[a]
}
muestra()
}

function pasa(dir)
{
if (dir=="i")
{
idx--
if (idx < 0) idx = afoto.length - 1
}
else
{
idx++
if (idx == afoto.length) idx = 0
}
muestra()
}

function muestra()
{
document.images["fotico"].src = afoto[idx].src
document.forms[0].leyenda.value = "Foto " + (idx+1) + " de " + afoto.length
}
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers[0].document.images[0].width;
window.innerHeight = document.layers[0].document.images[0].height;
}
if (isIE4) {
window.resizeTo(500, 500);
width = 500 - (document.body.clientWidth - document.images[0].width);
height = 500 - (document.body.clientHeight - document.images[0].height);
window.resizeTo(width, height);
}
}
// -->
</script>
<BODY onLoad="fitWindowSize()">
<form>
<input type="button" value="anterior" onclick="pasa('i')">
<input type="button" value="siguiente" onclick="pasa('d')">
</form>
<img id="fotico">
</body>


Y nada que no tira para nada......
  #6 (permalink)  
Antiguo 11/10/2005, 09:13
Avatar de pinchoso  
Fecha de Ingreso: octubre-2005
Ubicación: Barcelona
Mensajes: 177
Antigüedad: 18 años, 6 meses
Puntos: 0
Hola luzin, mira te paso el codigo de mi página directamente:

<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
<!--
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers[0].document.images[0].width;
window.innerHeight = document.layers[0].document.images[0].height;
}
if (isIE4) {
window.resizeTo(500, 500);
width = 500 - (document.body.clientWidth - document.images[0].width);
height = 500 - (document.body.clientHeight - document.images[0].height);
window.resizeTo(width, height);
}
}
// -->

function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>
<link href="<%=Session("cssFile")%>" rel="stylesheet" type="text/css">
</HEAD>

<title><%=image_name%></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<BODY onLoad="fitWindowSize()">

<div style="position:absolute; left:0px; top:0px"> <img src="img/imagen.jpg">
</div>

</BODY></html>

No hagas caso de los tags entre <% %> la página originalmente es un ASP, o sea que sudando de eso....a mi me funciona

Bueno, suerte!
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 09:50.