Bonjour,

je suis calé dans ce tuto au moment où il faut afficher l'image, elle ne s'affiche pas chez moi. J'ai beau chercher sur google, je ne vois pas l'erreur, savez-vous m'aider ?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Lightbox perso</title>
<link rel="stylesheet" href="mybox.css" type="text/css" media="screen" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" /></script>
</head>
<body>
<div id="conteneur">
    <h1>TEST d'un lightbox perso</h1>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. <a href="ExpoPeinture.jpg" rel="maboite">LIENS A ESSAI</a></p>

    <a href="ExpoPeinture.jpg" rel="maboite"><img src="btn-ExpoPeinture.jpg" /></a>

</div>
</body>
<script>
$(document).ready(function(){
    maboite.init();

});
maboite={
    init:function(){
        maboite.opacite=0.7;
        maboite.duree=1000;

        $("a[rel='maboite']").click(function(){
            maboite.lien=$(this).attr("href");
            maboite.open(maboite.lien);
            return false;
        });
    },
    open:function(lien){
        maboite.lien=lien;
        $('body').append('<div id="maboite"><div id="maboite_aplat"></div><div id="maboite_loader"></div><div id="maboite_conteneur"><div id="maboite_relative"><div id="maboite_close"></div><div id="maboite_contenu"></div></div></div></div>');
        $('#maboite_conteneur').hide();
        $('#maboite_loader').hide().fadeIn();
        $('#maboite_aplat').hide().fadeTo(500,maboite.opacite);

        maboite.img=new Image();
        maboite.img.src=maboite.lien;
        maboite.timer=window.setInterval(maboite.load,100);
    },
    load:function(){
        if(maboite.img.complete){
            window.clearInterval(maboite.timer);
            maboite.anim();
        }
    },
    anim:function(){
        $('#maboite_conteneur').show();
        maboite.largeur=maboite.img.width;
        maboite.hauteur=maboite.img.height;
        $('#maboite_contenu').append('<img src="+maboite.lien+"/>');
        $('#maboite_contenu img').hide();
        $('#maboite_close').hide();
        $('#maboite_conteneur').animate({width:maboite.largeur},500).animate({height:maboite.hauteur},500,function(){
            $('#maboite_close').fadeIn();
            $('#maboite_contenu img').fadeIn();
            $('#maboite_loader').hide();
        });
    }
}

</script>

</html>

Merci

2 réponses


djtec
Réponse acceptée

Ligne 60 tu écris: '<img src="+maboite.lien+"/>' essaye en mettant '<img src="'+maboite.lien+'"/>' car c'est mal concaténé entre les simple et double quote

taekwon
Auteur

Merci beaucoup pour votre réponse, c'est bien ça qu'il me manquait, en plus, j'ai vu ça dans une formation en JAVA (pas Javascript) mais j'avais oublié.