Hello, I had been given this code to play a single sound file embedded
in a page. Sadly, the code doesn't actually "play" any sound file.
Could you help supply some JS code that will play a sound file for both
IE and Mozilla?
Thanks, - Dave
<html>
<head>
<title>Make some noize</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.create Element("bgsoun d");
elm.src = src;
}
else {
elm = document.create Element("object ");
elm.setAttribut e("data",src) ;
elm.setAttribut e("type","aud io/x-wav");
elm.setAttribut e("controller", "true");
}
document.body.a ppendChild(elm) ;
this.elm = elm;
return true;
};
Sound.stop = function Sound_stop() {
if (this.elm) {
this.elm.parent Node.removeChil d(this.elm);
this.elm = null;
}
};
//-->
</script>
</head>
<body>
<div
onmouseover="So und.play('klats chn.wav')"
onmouseout="Sou nd.stop()">Come over me</div>
</body>
</html>
in a page. Sadly, the code doesn't actually "play" any sound file.
Could you help supply some JS code that will play a sound file for both
IE and Mozilla?
Thanks, - Dave
<html>
<head>
<title>Make some noize</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.create Element("bgsoun d");
elm.src = src;
}
else {
elm = document.create Element("object ");
elm.setAttribut e("data",src) ;
elm.setAttribut e("type","aud io/x-wav");
elm.setAttribut e("controller", "true");
}
document.body.a ppendChild(elm) ;
this.elm = elm;
return true;
};
Sound.stop = function Sound_stop() {
if (this.elm) {
this.elm.parent Node.removeChil d(this.elm);
this.elm = null;
}
};
//-->
</script>
</head>
<body>
<div
onmouseover="So und.play('klats chn.wav')"
onmouseout="Sou nd.stop()">Come over me</div>
</body>
</html>
Comment