I spent some time playing with this and couldn't find a
really satisfying solution. The following code *sort of*
works (if all on one line, and if player is the name of
the Media Player object):
<a href="javascript:;"
onclick="player.URL='sounds/dog.wav';player.controls.play
();">Play</a>
but even though the sound plays, I get an error message
stating that the play method isn't available. There's a
fix for that error message -- I could change some
security settings and then rerun Media Player setup, but
how many Web visitors are going to discover the same
problem, find the fix, and then apply it, just for your
Web site?
If you have Frontpage 2003, a much better solution is to
forget Media Player, and just use the Play Sound
behavior. To do this, you select the text that will
trigger the sound, display the Behaviors task pane, click
Insert, choose Play Sound, and specify the sound file you
want.
If you have FP2002 or earlier, paste this script into the
<head> section of your page:
<script language="JavaScript">
<!--
function playIt(path) {
var b,e,es,i
var d=document
var se="<EMBED SRC='"+path+"' HIDDEN=TRUE LOOP=FALSE
AUTOSTART=TRUE>";
if(d.body) b=d.body;
if(d.getElementsByTagName) {
es=d.getElementsByTagName('embed')
for(i=0;i<es.length;i++) {
e=es(i);
if( e.src==path ) {
if(e.removeNode) e.removeNode();
break;
}
}
if(b&&b.insertAdjacentHTML) b.insertAdjacentHTML
("beforeend",se);
}
}
// -->
</script>
and then code your hyperlink:
href="javascript
layIt(sounds/DOG.WAV')"
Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------