Click to See Complete Forum and Search --> : Multiple Actions on one click


Rntaboy
03-13-2003, 08:49 PM
I am making a menu for a website. I want it to play a sound, and do a roll over when I click it. I was just wondering if this is possible. I tried it, but adding the rollover code above or below the sound code, makes it so neither works.
Here is the working sound code:

<html>
<head>
<base target="main">
<head>
<script language="javascript" type="text/javascript">
var aySound = new Array();
// Below: source for sound files to be preloaded
aySound[0] = "siren.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>
</Head>

<Body background="Images\leftback.jpg" alink=black vlink=black link=black>
<A HREF="Home.html" onclick="playSound(0)"><img src="Images\minilogoin.jpg" width=80%></A>
<A HREf="members.html"><img src="Images\membersin.jpg" width=80%></A>
<A HREF="media.html"><img src="Images\mediain.jpg" width=80%></A>
<A HREf="Links.html"><img src="Images\linksin.jpg" width=80%></A>
</body>
</html>

Could someone show me how to do this if it is possible.

Rntaboy
03-14-2003, 09:39 AM
PLZ PEOPLE
I need help. I'm sure one of you all knowing web gods has an answer to this ever soooooo simple question.
PLZZZZ HELP!

pyro
03-14-2003, 10:38 AM
I don't see any rollover code in there...

Rntaboy
03-14-2003, 02:12 PM
That code is the working code for the Sound onmouseclick.
I was wondering where to place the rollover code.

pyro
03-14-2003, 02:17 PM
Post what you tried...

Rntaboy
03-14-2003, 04:28 PM
Code I tried:

<html>
<head>
<base target="main">
<head>
<script language="javascript" type="text/javascript">
var aySound = new Array();
// Below: source for sound files to be preloaded
aySound[0] = "siren.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>
</Head>

<Body background="Images\leftback.jpg" alink=black vlink=black link=black>
<A HREF="Home.html" onclick="playSound(0)" onclick="document.arrow.src='images\minilogoout.jpg'><img src="Images\minilogoin.jpg" width=80%></A>
<A HREf="members.html"><img src="Images\membersin.jpg" width=80%></A>
<A HREF="media.html"><img src="Images\mediain.jpg" width=80%></A>
<A HREf="Links.html"><img src="Images\linksin.jpg" width=80%></A>
</body>
</html>

I would like to eventually add the script that makes the images preload.
This is the base code which I got from Javascriptworld
<TITLE>A Simple Rollover</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers

if (document.images) {
arrowRed = new Image
arrowBlue = new Image

arrowRed.src = "images/redArrow.gif"
arrowBlue.src = "images/blueArrow.gif"
}
else {
arrowRed = ""
arrowBlue = ""
document.arrow = ""
}

// End hiding script from old browsers -->
</SCRIPT>

Rntaboy
03-15-2003, 11:30 AM
Anybody? Anybody? Bueller? Bueller?

pyro
03-15-2003, 06:05 PM
I don't see any onmouseover commands in there. You have an onclick, but no onmousover...

Rntaboy
03-15-2003, 11:16 PM
Maybe roll over is not the right word.
The idea is that the person clicks image1, which looks like a button. Then at the same time, a siren goes off and the image switches to image2, which is of a depressed button.
How might I do that.

pyro
03-16-2003, 12:17 PM
Try this:

<a href="Home.html" onclick="playSound(0); document.arrow.src='images\minilogoout.jpg';"><img src="Images\minilogoin.jpg" width=80%></a>