Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

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:

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

Where the hidden frame is something like:

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

©2018 Martin Webb