Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    253

    pop up centrata e si dimensiona a seconda dell'img

    Ciao amici!
    Vi chiedo un aiuto, ho fatto questa funzione che prende la foto l'adatta alle dimensioni e la centra alla pagina:

    function dlApriFinestraZoom(page)
    {

    var w = 600;
    var h = 800
    var l = Math.floor((screen.width - w) / 2);
    var t = Math.floor((screen.height - h) / 2);
    cmd = "zoom.htm?Foto=" + page;

    vReturnValue = window.open(cmd, "", "toolbar=no,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t + ",status=no,scrollbars=no,resizable=0");
    return false;

    }
    richiamo la funzione:
    [img]img/logofirefox.png[/img]

    zoom.htm

    <script type="text/javascript" language="javascript">
    function imageLoader()
    {
    querystring = location.href;
    pos1 = querystring.indexOf("?Foto");

    if (pos1 != -1 )
    {
    pos1 += 6;
    file = querystring.substr(pos1);
    document.getElementById("foto").src = "img/" + file;
    }
    }
    function imageLoaded()
    {
    window.resizeTo(document.images[0].width+10,document.images[0].height+10);
    }
    </script>
    </head>
    <body topmargin="0" leftmargin="0" onLoad="imageLoader()">
    <img name="foto" id="foto" onLoad="imageLoaded()" onclick="window.close()">
    </body>

    ecco questa funzione che ho fatto prende in automatico l'immagine e si adatta alle dimensioni, però vorrei far in modo che si centri alla pagina e se la foto è piu' larga che alta, non si centra...come posso fare? ho provato anche con un if non sono riuscita...
    Grazie mille per l'aiuto!

  2. #2
    Utente di HTML.it L'avatar di Virus_101
    Registrato dal
    Sep 2008
    Messaggi
    2,497
    Se nn ho visto male hai dimenticato un passaggio.

    Le immagini hanno tte dimesioni 800x600?

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    253
    ciao!
    Grazie prima di tutto per la risposta!
    Eh no...io come dimensione fissa ho impostato quella...ma di fatto ci sono foto o piu' larghe e meno lunghe o viceversa..


    mmm cmq i passaggi li ho riportati tutti..

    ho provato a fare anche una cosa così ma non ha senso..perchè prende sempre i valori che dichiaro...

    function dlApriFinestraZoom(page) {

    var w = 567;
    var h = 850;


    var l = Math.floor((screen.width - w) / 2);
    var t = Math.floor((screen.height - h) / 2);
    cmd = "zoom.htm?Foto=" + page;

    if (w == 567 || h == 850)
    {
    vReturnValue = window.open(cmd, "", "toolbar=no,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t + ",status=no,scrollbars=no,resizable=0");
    }
    else (w == 1090 || h == 296)
    {
    vReturnValue = window.open(cmd, "", "toolbar=no,width=" + w + ",height=" + h + ",left=500,top=700,status=no,scrollbars=no,resizab le=0");
    }

    /*vReturnValue = window.open(cmd, "", "toolbar=no,width=" + w + ",height=" + h + ",left=300,top=200,status=no,scrollbars=no,resizab le=0");*/
    return false;
    }

  4. #4
    Utente di HTML.it L'avatar di Virus_101
    Registrato dal
    Sep 2008
    Messaggi
    2,497
    Ok allora fai cosi'
    Codice PHP:
    function dlApriFinestraZoomimgW imgH page) {

    var 
    imgW;
    var 
    imgH;


    var 
    Math.floor( (screen.width - (w/2) ) / 2);
    var 
    Math.floor( (screen.height - (h/2) ) / 2);
    cmd "zoom.htm?Foto=" page;

    ...... 

  5. #5
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    253
    ciao grazie!
    sarebbe così:


    function dlApriFinestraZoom(imgW, imgH, page)
    {

    var w = imgW;
    var h = imgH;


    var l = Math.floor( (screen.width - (w/2) ) / 2);
    var t = Math.floor( (screen.height - (h/2) ) / 2);
    cmd = "zoom.htm?Foto=" + page;
    vReturnValue = window.open(cmd, "", "toolbar=no,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t + ",status=no,scrollbars=no,resizable=0");

    return false;
    }



    <a href="#" onclick="dlApriFinestraZoom('montali1.jpg')">

  6. #6
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    253
    il fatto è che non riceve l'immagine...

  7. #7
    Utente di HTML.it L'avatar di Virus_101
    Registrato dal
    Sep 2008
    Messaggi
    2,497
    esatto perche' senno posizionavi l'immagine a meta' della finestra.
    Ma non posizionavi lìimmagine al centro.


    facevi una cosa come :

    finestra x px
    |---- ---- ---- ----|

    img w px
    X---- ----X

    finestra/2
    |---- ----|

    metti immagine
    |---- ---- X---- ----X|

    invece dovevi riposizionare anche l'immagine indietro della meta della sua dimensione
    quindi
    |---- X---- ----X ----|

    Che e' corretto.

  8. #8
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    253
    ahh s si ho capito, però come faccio a fargli pervernire l'immagine? non me la mostra...

  9. #9
    Utente di HTML.it L'avatar di Virus_101
    Registrato dal
    Sep 2008
    Messaggi
    2,497
    Codice PHP:

    function dlApriFinestraZoom(imgWimgHpage)
    {

    var 
    imgW;
    var 
    imgH;


    var 
    Math.floor( (screen.width - (w/2) ) / 2);
    var 
    Math.floor( (screen.height - (h/2) ) / 2); 

    cmd "zoom.htm?Foto=" page;

    if (
    == 567 || == 850)
    {
    vReturnValue window.open(cmd"""toolbar=no,width=" ",height=" ",left=" ",top=" ",status=no,scrollbars=no,resizable=0");
    }
    else (
    == 1090 || == 296)
    {
    vReturnValue window.open(cmd"""toolbar=no,width=" ",height=" ",left=500,top=700,status=no,scrollbars=no,resizable=0");
    }

    /*vReturnValue = window.open(cmd, "", "toolbar=no,width=" + w + ",height=" + h + ",left=300,top=200,status=no,scrollbars=no,resizable=0");*/
    return false;

    Bstabva solo che modificassi 2 calcoli e la firma della funzione. il resto dovrebbe andare

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.