#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    3
    Rep Power
    0
    function leftchange() {
    var leftimages = new Array(3);
    for(var i = 0; i < 3; i++) {
    leftimages[i] = new Image();
    leftimages[i].src = "images/left" + i + ".gif";
    }
    var random = Math.floor(Math.random()*3);
    left.src = leftimages[random].src;
    setTimeout(leftchange, 3000);
    }

    There's my code. It is located in the head. In the body, I use an onLoad to call the function. Later on in the actual document, I call and <img name="left" src="whatever" width and height stuff>

    Anyhow - ie 5.01 likes my code and causes the image to change. Netscape gives me an error saying that left is not defined and another person, unknown IE version was able to tell that img's were downloading, but not changing.

    I'm not too good w/ JavaScript and so I'm hoping that someone can help me with this problem.

    Thanx.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    are your images in a <div></div> (layer)?
    if so you need to explicitly tell netscape where the image is so while ,

    if(document.all){
    document.images[img_name].src =img_src
    } else {
    document[img_name].src=img_src
    }
    works when there is only 1 layer you need -

    if (document.all) {
    document.images[img_name].src=img_src
    } else {
    document[div].document[img_name].src=img_src
    }

    for nested or multiple layers.

    hope that helps?


    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    SPAIN
    Posts
    47
    Rep Power
    15
    But in most cases, the easiest way is type document.left.src=.... instead of left.src alone, this way, you don't have to add anything else to your script

    It works in NS

    [This message has been edited by Argrajoca (edited April 19, 2000).]
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    3
    Rep Power
    0
    Thanx for y'alls help.
    I appreciate it.

Similar Threads

  1. Ensuring a file's code doesn't cause error in another.
    By Jason Doucette in forum C Programming
    Replies: 0
    Last Post: February 6th, 2004, 01:51 PM
  2. How can you execute c/c++ code within asp.net?
    By aceduk in forum ASP Programming
    Replies: 3
    Last Post: October 6th, 2003, 10:31 AM
  3. Replies: 2
    Last Post: July 9th, 2003, 02:27 AM
  4. Random code generator
    By quiquedcode in forum PHP Development
    Replies: 2
    Last Post: November 26th, 2002, 12:58 PM
  5. How > To > Do > Menus > Like > This?
    By bonkerz in forum PHP Development
    Replies: 2
    Last Post: October 27th, 2001, 02:44 AM

IMN logo majestic logo threadwatch logo seochat tools logo