Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-23-2005, 04:25 AM   PM User | #1
buckmana
New to the CF scene

 
Join Date: Mar 2005
Location: Australia
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
buckmana is an unknown quantity at this point
Unhappy Image rollover and sound

I've been experimenting with Javascript in making a protoype webpage. Note: my knowledge of Javascript is very limited, I found tutorials on the net that explained what I needed to do and modified the code for my own use.

Basically, for the page I am working on currently, there need to be three Javascript functions. I've worked out the first two, the third is actually a combination of these two.

The first function swaps an image for onMouseover.
The second function plays a sound whenever a picture on the page is clicked.

I've tried to combine the functions with little success so far.
What I need to happen is have the images "swap" while the sound plays (this happens when the image is clicked with the mouse), which should both be triggered by onClick. The image also has to be constrained by the height command, although this isn't strictly necessary if the function works.

And I need to have all three functions run on the same page. The third function needs to be created anew.

I would greatly appreciate any help I can get.

Here is the code, extracted from the webpage:

<script language="JavaScript" type="text/javascript">
<!--
image1of = new Image(); image1of.src = "Return_Off.gif";
image1on = new Image(); image1on.src = "Return_On.gif";

function imageReplace() {
var args = imageReplace.arguments;
for (var i = 0; i < args.length; i = i + 2) {
document[args[i]].src = eval(args[i + 1] + ".src");
}
}
// -->
</script>

<script>
function EvalSound(soundobj) {
var thissound= eval("document."+soundobj);
thissound.Play();
}
</script>

<embed src="Cmctr.wav" autostart=false hidden=true name="sound1"
enablejavascript="true">



<img src="M\Mnnctr.gif" width="150" onClick="EvalSound('sound1')">



<a href="javascript:history.go(-1)"
onMouseout= "imageReplace('image1','image1of');"
onMouseover="imageReplace('image1','image1on');">
<img src="Return_Off.gif" name="image1"
alt="Return" border="0"></a>
buckmana is offline   Reply With Quote
Old 03-23-2005, 09:28 AM   PM User | #2
evo
waka Ionsurge


 
Join Date: Feb 2005
Location: United Kingdom
Posts: 881
Thanks: 5
Thanked 12 Times in 12 Posts
evo is an unknown quantity at this point
--> Shifting to JavaScript.
evo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:00 AM.


Advertisement
Log in to turn off these ads.