GotFusion.com Where your journey begins
Antons Video ProductionsNetObjects Fusion 7 Websites Portal

 


 


By placing this Javascript in the  <HEAD> of a page you can get the visitors computer to sound off when their pointer goes over a hot spot on your page

<script language="javascript"><!--
// Preload and play audio files with event handler (MouseOver sound)

var aySound = new Array();

// Below: source for sound files to be preloaded
// replace ????.wav with a wave file under 6k
// do not use more than 2 files for speed of load
// IE with a Mac does not support this playsound
// add additional sounds with
// aySound[1] = "????.wav";
// aySound[2] = "????.wav";
// etc

aySound[0] = "????.wav";

// DO NOT CHANGE ANYTHING BELOW THIS LINE
document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;

function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
//-->
</script>

Copy the script to notepad and save it for future use. Bring up the layout properties pallet by clicking in a layout reign or by pressing F9.  Click the HTML button and paste this script in the first tab (Between Head Tags). Don't forget to replace the ?????.wav with the wave file you want to play. Try to use files of less than 6k in size.

To activate the sound:

  • Place some text on your page and highlight it (or click it if you want to use an image)
  • Click the link button on the properties palette
  • select your link (or use smart link > blank if you just want the sound without a link)
  • Click the HTML button and past the following code in the center tab (Inside Link)

onMouseOver="playSound(0)"

If you are using a larger wave file and want the sound to stop when the mouse goes off use this group of code.

onMouseOver="playSound(0)";onMouseOut="stopSound(0)"

This is a persnickety script and you may find that it will conflict with other functions on your page (DHTML etc.) that will keep this script from executing (it will NOT execute on this page because of the DHTML menu structure). It also does not work on Internet Explorer on Mac computers..... Use it if you can but don't bust a gut trying to get it to work everywhere.  Besides it can be rather annoying at times, depending on what you are using for the sound.

If you want to see a page with three sounds on mouseOver links look at this URL:

link to page with three mouse over sound example

View the PREVIOUS page

Return to the TOP of this page

View the NEXT page in this tutorial


|  Fusion  |  Web Design  |  Hosting  |  Resources  |  gotFusion Store  | 

Problems with this page?  

All content copyright © 2002, 2003 gotFusion LLC.  The name gotFusion and the gotFusion ® logo are registered trademarks of gotFusion LLC
Copyright, legal notice & privacy statement