PDA

View Full Version : Script sound notification not working on mozila firefox



mutago
10-02-2013, 05:52 PM
This chat sound notification script works on Internet Explorer, Safari and google chrome.
But does not work on mozila firefox. can someone help me to fix that or an alternative that can work in all browsers


<html><head></head>


<script type="text/javascript">
var soundObject = null;
function PlaySound() {
if (soundObject != null) {
document.body.removeChild(soundObject);
soundObject.removed = true;
soundObject = null;
}
soundObject = document.createElement("embed");
soundObject.setAttribute("src", "notify.wav");
soundObject.setAttribute("hidden", true);
soundObject.setAttribute("autostart", true);
document.body.appendChild(soundObject);
}


</script>
<body>
<embed src="notify.wav" autostart=false width=0 height=0 id="boom"
enablejavascript="true">
</form method="post" action="dd.php">
<input name="message" type="text" placeholder="Chatting" />
<input name="reciever" type="hidden" value=""><br>

<input name="submit" type="submit" value=Chat3 id="post_button" onClick="PlaySound()"/>
</form>


</body>
</html>

jscheuer1
10-02-2013, 06:41 PM
The fox doesn't like width=0 height=0. Change the embed tag to:


<embed src="notify.wav" autostart=false hidden=true id="boom"
enablejavascript="true">

mutago
10-02-2013, 08:38 PM
It seems not to work. it says additional plugin is required to display all the media on this page.

jscheuer1
10-02-2013, 09:42 PM
OK, well that can happen. The .wav format generally uses QuickTime - though it could use other plugins. If QT isn't installed and there's no other plugin installed that can take care of it for you, you will get that message. Something similar will happen in any other browser. If that browser has no plugin installed that can handle the embed, then it will not work and there may or may not be a notification. Worked fine here in Firefox once I changed the the embed tag as I described.

You could use an HTML 5 audio tag, but that's complicated and you would still need a backup for browsers that don't support it or that don't support .wav in it (IE).

Here it is without backup. When I get some more time I'll show you how to do it with backup, either browser sniffing, or feature detection. The latter if that's feasible:


<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
#thesound {
position: absolute;
top: -3000px;
left: -3000px;
}
</style>
</head>
<body>
<audio id="thesound">
<source src="notify.wav" type="audio/x-wav">
</audio>
<form method="post" action="dd.php" onsubmit="return false">
<input name="message" type="text" placeholder="Chatting" />
<input name="reciever" type="hidden" value=""><br>

<input name="submit" type="submit" value=Chat3 id="post_button" onClick="document.getElementById('thesound').play()"/>
</form>
</body>
</html>



See how that works in the fox, it might still not, if your copy of Firefox doesn't support the tag, or doesn't have a codec for .wav, it will still fail.

jscheuer1
10-03-2013, 01:30 AM
OK, try this out:

5240

mutago
10-04-2013, 05:45 AM
its working now. Thank you so much