Page html aléatoire

kigiboy Messages postés 5 Date d'inscription   Statut Membre Dernière intervention   -  
 Wish -
Bonjour, j'aimerai avoir votre aide pour résoudre le point suivant :
j'ai crée 4 swf appellés 1.swf 2.swf 3.swf 4.swf

Ils sont placés à la racine de mon site.

Comment je peux faire pour lorsque j'arrive sur mon index.html une de ces animation s'affiche aléatoirement (sans clic sur un lien pour activer l'animation).

Bref lorsque l'on arrive sur mon site une des 4 anim swf se lance aléatoirement et automatique .

Merci à vous tous.
Jean Baptiste
A voir également:

8 réponses

gryzzly Messages postés 4608 Date d'inscription   Statut Contributeur Dernière intervention   1 335
 
automatique : ca s'est propriété du swf
aléatoire : javascript je pense, regarde du coté des images aléatoires
0
myrtie
 
Bonjour,

je cherche également à produite ce même effet d'animation flash aléatoire. As tu trouvé une solution ?
Merci de ta réponse.

Myrtie.
0
Ixion
 
Bonjour,

Il fut un temps où j'avais trouvé ceci qui fontionne très bien avec les .swf :



function banniere()
{
numimage= Math.round(Math.random()*(nbimage-1)+1);

if (numimage <= 10)
{width = 600;
height = 120;
url = "repertoire/anim.swf";}

if (numimage > 10 && numimage <= 20)
{width = 655;
height = 120;
url = "repertoire/anim2.swf";}

if (numimage > 20 && numimage <= 30)
{width = 655;
height = 120;
url = "repertoire/anim3.swf";}

document.write('<object codebase="http://fpdownload2.macromedia.com/get/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width=' + width + ' height=' + height + '>')
document.write('<param name="movie" value="%27%20%2B%20url%20%2B%20%27">')
document.write('<param name="menu" value="false">')
document.write('<param name="quality" value="high">')
document.write('<param name="LOOP" value="false">')
document.write('<embed src="%27%20%2B%20url%20%2B%20%27" quality="high" loop="false" width=' + width + ' height=' + height + ' pluginspage="https://get.adobe.com/flashplayer/" type="application/x-shockwave-flash"></embed>')
document.write('</object>')
}



Et puis ajouter ceci dans le body à l'endroit voulu :

<script language="JavaScript">banniere();</script>
0
myrtie
 
Merci de ta réponse.

Je viens juste d'essayer.

Mais cela ne marche pas du tout chez moi. Aucune animation ne s'affiche.

En faite, je veus juste alterner deux animations flash à chaque réactualisation du navigateur.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Ixion
 
Tu as bien pensé à changer le nom des fichiers voulu :

url = "repertoire/anim.swf";}

Si tu n'as que deux animations, il faut supprimer la dernière :
if (numimage > 20 && numimage <= 30)
{width = 655;
height = 120;
url = "repertoire/anim3.swf";}
0
myrtie
 
Oui, oui, j'ai bien changé les urls et ajouté ton code...

J'ai aussi supprimé la reférence à l'animation 3... rien :-(


Voici le code ajouté dans une page :
<!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=iso-8859-1" />
<title>Document sans nom</title>
<script language="JavaScript" type="text/javascript">
function banniere()
{
numimage= Math.round(Math.random()*(nbimage-1)+1);

if (numimage <= 10)
{width = 800;
height = 520;
url = "images/printemps.swf";}

if (numimage > 10 && numimage <= 20)
{width = 800;
height = 520;
url = "images/news.swf";}


document.write('<object codebase="http://fpdownload2.macromedia.com/get/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width=' + width + ' height=' + height + '>')
document.write('<param name="movie" value="%27%20%2B%20url%20%2B%20%27">')
document.write('<param name="menu" value="false">')
document.write('<param name="quality" value="high">')
document.write('<param name="LOOP" value="false">')
document.write('<embed src="%27%20%2B%20url%20%2B%20%27" quality="high" loop="false" width=' + width + ' height=' + height + ' pluginspage="https://get.adobe.com/flashplayer/" type="application/x-shockwave-flash"></embed>')
document.write('</object>')
}
</script>
</head>

<body>
<script language="JavaScript">banniere();</script>
</body>
</html>
0
Wish
 
C'est un peu tard mais cela pourra peut être aider d'autres personnes :
<?
$nbimages=4; //mettre le nombre d'image
$nomimages[1]="animation01.swf";
// votre swf, attention s'ils ne sont pas dans le même dossier, rajouter le -> mon_dossier/animation01.swf -----

$nomimages[1]="animation02.swf";
$nomimages[1]="animation03.swf";
$nomimages[1]="animation04.swf";


srand((double)microtime()*1000000);

$affimage=rand(1,$nbimages);


echo("<object type='application/x-shockwave-flash' data=http://ton_site/repértoire_ou_tu_ranges tes swf/".$nomimages[$affimage]." width='xxx' height='xxx'><param name='movie' value=http://ton_site/repértoire_ou_tu_ranges tes swf/".$nomimages[$affimage]."><param name='WMode' value='Transparent'></object>");

?>

Ca marche sur IE et firefox :-))
0
Wish
 
oops,

c'est

$nomimages[1]="animation01.swf";
$nomimages[2]="animation02.swf";
$nomimages[3]="animation03.swf";
$nomimages[4]="animation04.swf";
0