Displaying a random image

Discussion in 'Javascript' started by robbiehenry@gmail.com, Sep 19, 2005.

  1. Guest

    There is this javascript reference site that I often use and I was
    looking for some script that would randomly show one of three images on
    page refresh.

    Here is the reference site that I use:
    http://www.chalcedony.com/javascript/scripts/index.html

    Here is their example:
    http://www.chalcedony.com/javascript/scripts/index.html

    Here is the page that I built for my company's site:
    http://www.otpp.com/web/website.nsf/web/newgraduates&students

    This works like a peach except for MAC IE in which it does not work at
    all and just displays a blank square no matter how many times you
    refresh the page.

    Here is the javascript header code:
    <script language="Javascript" type="text/javascript">
    <!-- Hide script from old browsers

    myPix = new
    Array("../web/bennertestimonial/$FILE/bennertestimonial.jpg","../web/cheungtestimonial/$FILE/cheungtestimonial.jpg","../web/ttrottestimonial/$FILE/ttrottestimonial.jpg")
    imgCt = myPix.length

    function choosePic() {
    if (document.images) {
    randomNum = Math.floor((Math.random() * imgCt))
    document.myPicture.src = myPix[randomNum]
    }
    }

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

    Here is the body onload:
    onload="choosePic()"

    Here is the image tag:
    <img src="../web/bennertestimonial/$FILE/bennertestimonial.jpg"
    width="565" height="177" alt="" border="0" name="myPicture">

    I would suspect that there is something in this javascrpt code that is
    not supported by the DOM on a MAC IE.

    Does anyone know what that is, know what a work around would be or how
    I can get this to work?

    All help is appreciated.
    , Sep 19, 2005
    #1
    1. Advertising

  2. ASM Guest

    wrote:
    > There is this javascript reference site that I often use and I was
    > looking for some script that would randomly show one of three images on
    > page refresh.
    >
    > Here is the reference site that I use:
    > http://www.chalcedony.com/javascript/scripts/index.html
    >
    > Here is their example:
    > http://www.chalcedony.com/javascript/scripts/index.html
    >
    > Here is the page that I built for my company's site:
    > http://www.otpp.com/web/website.nsf/web/newgraduates&students
    >
    > This works like a peach except for MAC IE in which it does not work at
    > all and just displays a blank square no matter how many times you
    > refresh the page.
    >
    > Here is the javascript header code:
    > <script language="Javascript" type="text/javascript">
    > <!-- Hide script from old browsers
    >
    > myPix = new
    > Array("../web/bennertestimonial/$FILE/bennertestimonial.jpg","../web/cheungtestimonial/$FILE/cheungtestimonial.jpg","../web/ttrottestimonial/$FILE/ttrottestimonial.jpg")
    > imgCt = myPix.length


    what does this $FILE in my javascript ?

    > function choosePic() {
    > if (document.images) {
    > randomNum = Math.floor((Math.random() * imgCt))


    document.images['myPicture'].src = myPix[randomNum]

    > }
    > }
    >
    > // End hiding script from old browsers -->
    > </script>
    >
    > Here is the body onload:
    > onload="choosePic()"
    >
    > Here is the image tag:
    > <img src="../web/bennertestimonial/$FILE/bennertestimonial.jpg"
    > width="565" height="177" alt="" border="0" name="myPicture">
    >
    > I would suspect that there is something in this javascrpt code that is
    > not supported by the DOM on a MAC IE.
    >
    > Does anyone know what that is, know what a work around would be or how
    > I can get this to work?
    >
    > All help is appreciated.
    >



    --
    Stephane Moriaux et son [moins] vieux Mac
    ASM, Sep 19, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren Clark

    Random NOt random?

    Darren Clark, Jun 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    443
    mikeb
    Jun 24, 2004
  2. http://www.visual-basic-data-mining.net/forum

    Displaying image after selecting an image file.

    http://www.visual-basic-data-mining.net/forum, Sep 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    342
    http://www.visual-basic-data-mining.net/forum
    Sep 15, 2004
  3. globalrev
    Replies:
    4
    Views:
    742
    Gabriel Genellina
    Apr 20, 2008
  4. Linda
    Replies:
    5
    Views:
    127
    Mick White
    Jan 7, 2005
  5. VK
    Replies:
    15
    Views:
    1,120
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page