<html>
<head>
<title>fais du bruit</title>
<script type="text/javascript">
<!--
var Sound = new Object();
Sound.play = function Sound_play(src) {
if (!src) return false;
this.stop();
var elm;
if (typeof document.all != "undefined") {
elm = document.createElement("bgsound");
elm.src = src;
}
else {
elm = document.createElement("object");
elm.setAttribute("data",src);
elm.setAttribute("type","audio/x-wav");
elm.setAttribute("controller","true");
}
document.body.appendChild(elm);
this.elm = elm;
return true;
};
Sound.stop = function Sound_stop() {
if (this.elm) {
this.elm.parentNode.removeChild(this.elm);
this.elm = null;
}
};
//-->
</script>
</head>
<body>
<!-- premier test sur un texte simple -->
<div style="background-color:#000;color:#fff;">
<h1 onmouseover="Sound.play('son.mp3')" onmouseout="Sound.stop()">survolez ce texte</h1>
</div>
<!-- deuxieme test sur un lien hypertexte -->
<div style="background-color:#ccc;">
<p>et avec un lien ?</p>
<a href="#" onMouseOver="Sound.play('son.mp3')" onmouseout="Sound.stop()">survolez ce lien</a>
</div>
</body>
</html>