Compatibilité script IE/NETSC/FIREFOX
Bonjour,
sur mon site, j'ai une musique de fond qui joue automatiquement en boucle tant qu'on appuye pas sur une image (via l'événement onclick)
Code:
1 2 3 4 5 6 7 8 9 10
|
<script type="text/javascript" language="javascript">
<!--
var nomFichier="music/hopeful.wav";
if (navigator.appName == "Microsoft Internet Explorer")
document.writeln ('<bgsound width="1" height="1" id="BGSOUND_ID" src="' + nomFichier + '" autostart="true" loop="infinite">');
else {
document.writeln ('<embed width="1" height="1" name="Bach" src="' + nomFichier + '" autostart="true" loop="true">')};
// -->
</script> |
voici ma fonction javascript :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
<script language="JavaScript">
<!--
var choix = false;
function change_image() {
if (choix == false) {
if (navigator.appName == "Microsoft Internet Explorer") document.all['BGSOUND_ID'].src='jsilence.mid';
else
{
self.document.Bach.stop();
}
window.document.image.src = "images/son_off_BP.jpg";
choix=true;
}
else if (choix == true) {
if (navigator.appName == "Microsoft Internet Explorer") document.all['BGSOUND_ID'].src='music/hopeful.wav';
else
{
self.document.Bach.play();
}
window.document.image.src = "images/son_on_BP.jpg";
choix=false;
}
}
</script> |
donc quand on clique sur mon petit haut-parleur, la musique doit stopper et mon image se change (haut-parleur barré), et quand on reclique sur l'image, la musique redémarre et on rechange d'image.
Cela marche très bien sous IE mais pas avec Netscape et Firefox...
Merci,