Full answer based on other comments above. Yes, this is basically a repetitive question, but he was pleasantly asked to remain in the unanswered repository of questions forever if someone did not answer him. Other people who ask this question find this answer, see Other related topics in the comments.
<BGSOUND id="BGSOUND_ID" LOOP=1 SRC="jsilence.mid"> <script type="text/javascript" language="JavaScript"> function onBlur() { document.body.className = 'blurred'; }; function onFocus(){ document.body.className = 'focused'; }; if (/*@ cc_on!@ */false) { // check for Internet Explorer document.onfocusin = onFocus; document.onfocusout = onBlur; } else { window.onfocus = onFocus; window.onblur = onBlur; } function playSound(audioURL) { if (document.body.className == 'blurred') { if (document.all) { document.all['BGSOUND_ID'].src=audioURL; } else { self.iplayer.location.replace('jsplayer.htm?'+audioURL); } setTimeout("stopSound();", 500); } } function stopSound() { if (document.all) { document.all['BGSOUND_ID'].src='jsilence.mid'; } else { self.iplayer.location.replace('jsplayer.htm?stop'); } } function NewMessage(message) { ShowMessage(message); playSound('ding.mid'); } </script>
This code will use the BGSound IE and opera tags to play sound if the user uses any of these browsers, otherwise he assumes that the page with the name iplayer has an iframe and uses the built-in third-party player. See the source for more details.
- Focus Code Source: Here
- Sound Source Here
source share