/    Sign up×
Community /Pin to ProfileBookmark

Need code review pls for preload and playing

I came across a slight variation of code I tried to use earlier for preloading and playing sound. I have edited in only my sound files information that reside in a folder called “mysoundsB”, then ran it — but the ‘onmouseover’ and ‘onclick’s are still not happening.

Asking for a review to see if there are code errors that I do not know and could be pointed out. Do I have a code error maybe in the BODY section?? If it looks like it should work as is, then I’ll have to dig deeper and see why it’s not happening on my end.

Below is the code that goes in the HEAD and BODY. Could someone pls review for correctness? Should it preload and play audio files?

[quote]


*****************************************

********* IN THE HEAD SECTION **************


*****************************************

<BGSOUND ID=”auIEEmb”>
<SCRIPT>
<!–
// MouseOver/MouseClick audio.
// by JS Archive – [url]http://jsarchive.8m.com[/url]

var ayAudio = new Array();
// Source for sound files to be preloaded
ayAudio[0] = “mysoundsB/chimes1.wav”;
ayAudio[1] = “mysoundsB/chimes2.wav”;
ayAudio[2] = “mysoundsB/chimes3.wav”;
ayAudio[3] = “mysoundsB/sound1.wav”;
ayAudio[4] = “mysoundsB/sound2.wav”;
ayAudio[5] = “mysoundsB/sound3.wav”;
ayAudio[6] = “mysoundsB/sound4.wav”;
ayAudio[7] = “mysoundsB/misc1.wav”;
ayAudio[8] = “mysoundsB/misc2.wav”;
ayAudio[9] = “mysoundsB/misc3.wav”;

function AudioCheck() {
var n = navigator.appName
if (n==”Netscape”) this.ns = true;
else if (n==”Microsoft Internet Explorer” && document.all) this.ie = true;
else this.noAudio = true;
}
onload = function() {
is = new AudioCheck()
if (is.noAudio) return;

var s = ”;
for (i=0; i<ayAudio.length; i++)
s += “<EMBED SRC='”+ayAudio[i]+”‘ AUTOSTART=’FALSE’ HIDDEN=’TRUE’>”

if (is.ns) {
auEmb = new Layer(0);
with (auEmb.document) { open();write(s);close() };
}
else document.body.insertAdjacentHTML(“BeforeEnd”,s);

auCon = is.ns? auEmb.document.embeds:auIEEmb;
auCon.ctrl = function(au,play) {
if (is.ie) this.src = play? ayAudio[au]:”;
else eval( “this[au].” + (play? “play()”:”stop()”) );
}
is.auDone = true;

}
function playAudio(whAu) { if (window.auCon) auCon.ctrl(whAu,1) }
function stopAudio(whAu) { if (window.auCon) auCon.ctrl(whAu,0) }
//–>
</SCRIPT>


*****************************************

********* IN THE BODY SECTION **************


*****************************************

<!– onMouseover sound –>

<A HREF=”javascript:void(0);” onMouseOver=”playAudio(0)” onMouseOut=”stopAudio(0)”>mouseover1</A>
<A HREF=”javascript:void(1);” onMouseOver=”playAudio(1)” onMouseOut=”stopAudio(1)”>mouseover2</A>
<A HREF=”javascript:void(2);” onMouseOver=”playAudio(2)” onMouseOut=”stopAudio(2)”>mouseover3</A>

<!– onClick link sound –>

<A HREF=”javascript:playAudio(3);”>clicklink1</A>
<A HREF=”javascript:playAudio(4);”>clicklink2</A>
<A HREF=”javascript:playAudio(5);”>clicklink3</A>
<A HREF=”javascript:playAudio(6);”>clicklink4</A>

<!– onClick button sound –>

<INPUT TYPE=”BUTTON” VALUE=”button1″ onClick=”playAudio(7)”>
<INPUT TYPE=”BUTTON” VALUE=”button2″ onClick=”playAudio(8)”>
<INPUT TYPE=”BUTTON” VALUE=”button3″ onClick=”playAudio(9)”>

[/quote]

JUST THOUGHT OF SOMETHING: the code in the BODY section is really all inside table commands (but removed all of that for this post), could that be why it’s not working for me??

If needed, here is the link as to where I got the code [url]http://jsarchive.8m.com/audio.html[/url]

Thank you for any advice. ~ Nina

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @CalifNina spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...