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

Q485 Is there any way to associate a sound on mouse over?

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

Q485 Is there any way to associate a sound on mouse over?

Try this:

<script language="JavaScript"><!--
var can_play = false;

var mimetype = 'audio/midi';

if (navigator.mimeTypes) {
    if (navigator.mimeTypes[mimetype] != null) {
        if (navigator.mimeTypes[mimetype].enabledPlugin != null) {
            can_play = true;
            document.write('<embed src="sound.mid" hidden=true loop=false autostart=false>');
        }
    }
}
if (document.all) {
    can_play = true;
    document.write('<embed src="sound.mid" hidden=true loop=false autostart=false>');
}

function playSound() {
    if (document.embeds && can_play) {
        if (navigator.appName == 'Netscape')
            document.embeds[0].play();
        else
            document.embeds[0].run();
    }
}

function stopSound() {
    if (document.embeds && can_play)
        document.embeds[0].stop();
}
//--></script>

<a href="#" onMouseover="playSound()" onMouseOut="stopSound()"><img src="image.gif" width="100" height="100" border="0"></a>

Feedback on 'Q485 Is there any way to associate a sound on mouse over?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


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