Visualizzazione dei risultati da 1 a 8 su 8
  1. #1

    [JSP] cambia immagine + dimanico

    Vorrei rendere questa funzione + dinamica visto che ho 4 immagini da cambiare e nn voglio riscrivere 4 volte la stessa funzione.
    Praticamnete questa funzione mi serve per farcambiare un'immagine quando passa su una parte mappata di quella immagine.

    function ChangeImage(imgName) {

    pchome.src = imgName;

    }
    poi ovviamente ho anche il ripristino della immagine...

    OnMouseOver="ChangeImage('images/home/pchome2.jpg')" OnMouseOut="RestoreImage('images/home/pchome.jpg')"

    e in <img gli metto id="pchome">

    per uno funge ma voglio farlo per le altre senza scrivere +codice .

    Grazie per l'aiuto
    ..meglio avere dei rimorsi che dei rimpianti!!

    Un saluto a tutti i progettisti Web

  2. #2
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    function ChangeImage(img, imgName) {
    img.src = imgName;
    }

    e alla funzione passi (this, "nome")
    dovrebbe andare, attento a dove metti l'handler

  3. #3
    e bhe ma con una sola variabile? magari gicando con i nomi visto che l'immagine che c'č varia di nome rispetto a quella che devo mettere solo di un 2 finale !

    io ho provato cos' ma non mi funge . che sbaglio

    function ChangeImage(imgName) {

    document[imgName].src = eval("images/home/" + imgName + "2.jpg");

    }

    ---

    OnMouseOver="ChangeImage('pchome')"
    <img .. id="pchome" >
    ..meglio avere dei rimorsi che dei rimpianti!!

    Un saluto a tutti i progettisti Web

  4. #4
    Utente di HTML.it L'avatar di userfra
    Registrato dal
    Jul 2001
    Messaggi
    1,418
    prova cosė

    tra l'head

    <script language="JavaScript1.2">

    function reapply(){
    setTimeout("slideit()",1000)

    return true
    }
    function reapply2(){
    setTimeout("slideit()",1000)

    return true
    }
    window.onerror=reapply;reapply2
    </script>
    <script language="JavaScript1.1">
    <!--
    var image1=new Image()
    image1.src="esempio1.jpg"
    var image2=new Image()
    image2.src="esempio2.jpg"
    var image3=new Image()
    image3.src="esempio3.jpg"
    var image4=new Image()
    image4.src="esempio4.jpg"
    var image5=new Image()
    image5.src="esempio5.jpg"
    var image6=new Image()
    image6.src="esempio6.jpg"
    //-->
    </script>

    nel body

    [img]esempio1.jpg[/img]
    <script>
    <!--
    ////change number of images below
    var number_of_images=6
    //change speed below (in seconds)
    var speed=3
    var step=1
    var whichimage=1
    function slideit(){
    if (!document.images)
    return
    if (document.all)
    slide.filters.blendTrans.apply()
    document.images.slide.src=eval("image"+step+".src" )
    if (document.all)
    slide.filters.blendTrans.play()
    whichimage=step
    if (step<number_of_images)
    step++
    else
    step=1
    if (document.all)
    setTimeout("slideit()",speed*1000+3000)
    else
    setTimeout("slideit()",speed*1000)
    }

    //-->
    </script>

  5. #5
    Ahhhh per fortuna volevo scrivere poco codice..
    No no lo volevo + snello possibile
    ..meglio avere dei rimorsi che dei rimpianti!!

    Un saluto a tutti i progettisti Web

  6. #6
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    document.images['name'].src=

  7. #7
    grazie Floyd ma nn ho capito come utilizzare quella stringa e nn mi sembrava che andasse bene

    ho risolto cosė anche se nn era quello che volevo maaa...

    if (document.images) {

    Im1on = new Image();
    Im1on.src = "images/home/a2.jpg";
    Im2on = new Image();
    Im2on.src = "images/home/b2.jpg";
    Im3on = new Image();
    Im3on.src = "images/home/c2.jpg";
    Im4on = new Image();
    Im4on.src = "images/home/d2.jpg";

    Im1off = new Image();
    Im1off.src = "images/home/a.jpg";
    Im2off = new Image();
    Im2off.src = "images/home/b.jpg";
    Im3off = new Image();
    Im3off.src = "images/home/c.jpg";
    Im4off = new Image();
    Im4off.src = "images/home/d.jpg";

    }

    function ImOn(imgName) {
    if (document.images) {
    document[imgName].src = eval(imgName + "on.src");
    }
    }

    function ImOff(imgName) {

    if (document.images) {
    document[imgName].src = eval(imgName + "off.src");
    }

    }

    grazie lo stesso a tutti ciao
    ..meglio avere dei rimorsi che dei rimpianti!!

    Un saluto a tutti i progettisti Web

  8. #8
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    quello che hai messo non va bene

    document.images["imageID"]

    This property is an array containing references to all the Image objects in the current document. These references are stored in the array in the order in which they are defined in the source code. The "imageID" argument is used to access items in the array and this can either be a string containing the image name as defined within the <IMG> tag in the HTML source, or an integer (with '0' being the first item in the array).

    Both examples below return the same results; the first uses the defined names of the images and the second uses their reference number within the array.

    Code:
    document.images["imagename1"]
    document.images["imagename2"]
    document.images["imagename3"]

    document.images[0]
    document.images[1]
    document.images[2]

    forse funziona con ie ma sicuramente non con tutti i browser

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 © 2024 vBulletin Solutions, Inc. All rights reserved.