Click to See Complete Forum and Search --> : onMouseover & onMouseout not working


CalifNina
06-02-2003, 08:24 PM
Hi, First time trying 'onMouseover.' I searched through this forum and found a previous thread on 'onMouseover' and 'onMouseout'; it suggested some code to use ... I took that and inserted my details, but is not working. I've spent about 2 hours changing and trying diff things -- can't get it to work. Need someone to review and see if they can determine what's wrong?

All original code is inserted below, my ONLY editing is in red text. NOTE: sound files are in the same directory but in a folder named "sounds2"

In HEAD section:
<SCRIPT LANGUAGE="JavaScript">
<!--
// Preload and play audio files with event handler (MouseOver sound)
// designed by JavaScript Archive, (c)1999
// Get more free javascripts at http://jsarchive.8m.com

var aySound = new Array();
// Below: source for sound files to be preloaded
aySound[0] = "sounds2/soundA.wav";
aySound[1] = "sounds2/soundB.wav";
aySound[2] = "sounds2/soundC.wav";
aySound[3] = "sounds2/soundD.wav";

// DO NOT edit 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>
In BODY section:

.
.
.
<img src="Point.gif"><a href="http://www.abcnews.com" onMouseover="playSound(0)"
onMouseout="stopSound(0)"><strong>"ABC"</strong></a>

<img src="Point.gif"><a href="http://www.cnn.com" onMouseover="playSound(1)"
onMouseout="stopSound(1)"><strong>CNN</strong></a>

<img src="Point.gif"><a href="javascript:playSound(2);" onMouseover="playSound(2)"
onMouseout="stopSound(2)"><strong>Sample 3</strong></a>

<img src="Point.gif"><a href="javascript:playSound(3);" onMouseover="playSound(3)"
onMouseout="stopSound(3)"><strong>Sample 4</strong></a>
I tried two methods to make it work- to get a total of four samples (two per method). I just do not get it. What is wrong -- my stuff?? the original code?? Pulling hair out and about to toss this laptop on the floor!! :mad: :confused: :mad: (NOTE: I did not insert those two faces in the code; rather there is a 'colon' and a 'P' that the 'stick out tongue' faces are in lue of.

Please plsssssss help. ~ Nina

havik
06-02-2003, 10:35 PM
Assuming the code worked from the previous thread, all I could think of is that your sound files aren't being referenced properly (but the way you stated it it appears they are).

Which thread was it?

Note: those smiley faces that appear within your code can be remedied and returned to : and p by disabling smiley faces in your post. You can find this option directly below the text area where you enter the posts message.

Havik

CalifNina
06-02-2003, 11:06 PM
At last, somebody replied! Thank You havik. Yes the source did work correctly. I am now at a loss, darn.

Other code samples anyone can offer??? Or fix this one?? Perhaps, did you look at their code I supplied -- does it look right??

I've seen the smiley disable option, ok now I know what to use it for, thks. BTW, here is where the code came from. The page used it and their example of onMouseover worked. Maybe if someone looked this link, they might see something wrong??

http://javascriptkit.com/script/script2/soundlink.shtml

I do have one question, even though it's not working for me, is the red code in the original posting proper in both locations?? I still don't know if it is correct or not, moreso this bottom section:

<img src="Point.gif"><a href="http://www.abcnews.com" onMouseover="playSound(0)"
onMouseout="stopSound(0)"><strong>"ABC"</strong></a>

<img src="Point.gif"><a href="http://www.cnn.com" onMouseover="playSound(1)"
onMouseout="stopSound(1)"><strong>CNN</strong></a>

<img src="Point.gif"><a href="javascript:playSound(2);" onMouseover="playSound(2)"
onMouseout="stopSound(2)"><strong>Sample 3</strong></a>

<img src="Point.gif"><a href="javascript:playSound(3);" onMouseover="playSound(3)"
onMouseout="stopSound(3)"><strong>Sample 4</strong></a>