Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Thanked 0 Times in 0 Posts

    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");
    // -->

    function EvalSound(soundobj) {
    var thissound= eval("document."+soundobj);

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

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

    <a href="javascript:history.go(-1)"
    onMouseout= "imageReplace('image1','image1of');"
    <img src="Return_Off.gif" name="image1"
    alt="Return" border="0"></a>

  2. #2
    waka Ionsurge
    Join Date
    Feb 2005
    United Kingdom
    Thanked 12 Times in 12 Posts
    --> Shifting to JavaScript.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts