Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Sound | Q1461 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.