Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1461 How can I use Javascript to play audio when the user downloads my site?

You are here: irt.org | FAQ | JavaScript | Sound | Q1461 [ previous next ]

Sorry, There is no simple sound script that will run in all browsers and I can give you one, but it will give a lot of javascirpt errors in Internet Explorer if there is no support for sound... Also it is very hard to play WHILE the site downloads...:

Load this sound.htm page in a hidden frame:

<html>
<head>
<script language="JavaScript"><!--
function playSound() {
    if (document.embeds) {
        if (navigator.appName == 'Netscape')
            document.embeds[0].play();
        else
            document.embeds[0].run();
    }
}
//--></script>
</head>
<body onLoad="playSound();parent.otherframe.location='realpage.html';">
<embed src="sound.mid" hidden=true loop=false autostart=true>
</body>
</html>

Where the hidden frame is something like:

<frameset rows="100%,*">
<frame src="about:blank" name="otherframe">
<frame src="sound.htm">
</frameset>

©2018 Martin Webb