Onload image stylesheet

Fermé
marcothedwarf Messages postés 258 Date d'inscription samedi 25 septembre 2010 Statut Membre Dernière intervention 11 novembre 2021 - 11 août 2012 à 02:22
sebooch Messages postés 563 Date d'inscription dimanche 25 avril 2010 Statut Membre Dernière intervention 4 janvier 2014 - 11 août 2012 à 11:30
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.
A voir également:

1 réponse

sebooch Messages postés 563 Date d'inscription dimanche 25 avril 2010 Statut Membre Dernière intervention 4 janvier 2014 22
11 août 2012 à 11:30
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