Please... help with Java script thanks

Discussion in 'JavaScript' started by bidge, Jul 30, 2006.

  1. #1
    Hi I'm a newbie here and very new to Java Scripting.
    I found this handy little script for randomizing links but
    cannot work out how to substitute a gif image as a
    button instead of the "random text" lineit uses. (see below)

    <SCRIPT LANGUAGE="JavaScript">
    // start of script
    // code by Joe Burns
    // Fixed up by Zusukar
    // Changed into a link-thing by Snowmit
    var links = 5;
    var dt = new Date();
    var hr = dt.getSeconds();
    var ra = hr % links;
    var re = ++ra;
    var msg="<A HREF=/JSBook/"+re+".html>random link";
    document.write(msg);

    </SCRIPT>
    </A>
    <P>


    I have spent hours with it :(
    any help will be greatly appreciated
     
    bidge, Jul 30, 2006 IP
  2. AoaoSo

    AoaoSo Peon

    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    var msg='<A HREF=/JSBook/'+re+'.html><img src='+re+'.gif/>';
     
    AoaoSo, Jul 30, 2006 IP
  3. bidge

    bidge Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi AoaoSo. Thank you for the reply. I still have a problem with the gif displaying. I checked the relative path of other images and pasted this into the code where you indicated but the gif will not display for some reason?

    Cheers
    Bidge
     
    bidge, Jul 30, 2006 IP
  4. AoaoSo

    AoaoSo Peon

    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    var msg='<A HREF=\/JSBook\/'+re+'.html ><img src=\/'+re+'.gif >';

    is there an example?
     
    AoaoSo, Jul 30, 2006 IP