Onload image stylesheet

marcothedwarf Messages postés 300 Statut Membre -  
 Utilisateur anonyme -
Bonsoir,

je souhaiterais exécuter une fonction après le chargement de mon background grâce à "onload".

Mon background est généré depuis ma stylesheet :

body {
height:100%;
background: url(images/bg.jpg) no-repeat;
overflow: hidden;
background-position:0% 23%;
}


Comment puis-je insérer ma fonction "onload", qui chargera une fonction dans le header de ma page ?

Merci,
MarcoTheDwarf.

1 réponse

  1. Utilisateur anonyme
     
    Salut

    Tu peux faire un truc comme cela :
    <head>
    <script>
      function loading(){
        var img_bg = new Image(500,500); // taille de ton image (width,height)
        img_bg.src = "adresse_de_ton_image";
    
        nom_de_ta_fonction(); // A charger après
    }    
    </script>
    </head>
    
    <body onload="javascript:loading();">

    0