Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dynamic table background image

    I have used this script below but all I get is a white screen. the paths to the images are correct.

    Can anyone help me please?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>
    </head>

    <body>
    <SCRIPT LANGUAGE="Javascript"><!--

    var arr = newArray("graphics/main_img1.jpg","graphics/main_img2.jpg","graphics/main_img3.jpg");

    var increment = Math.floor(Math.random() * arr.length);

    //pre-load image
    var img = new Image();
    img.src=arr[increment];

    window.onload=function(){
    document.getElementById('tblID').style.background="white url("+img.src+") no-repeat fixed center"
    }


    //--></SCRIPT>
    <table id="tblID">
    <tr>
    <td width="500" height="500"></td>
    </tr>
    </table>


    </body>
    </html>
    Last edited by andyc209; 03-14-2004 at 07:38 PM.

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I usually put a \ before a / in javascripts I believe

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    newArray is two words.

    eg:
    This: arr = newArray
    Should be: arr = new Array

    .....Willy

  • #4
    New Coder
    Join Date
    Jun 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the replys, it works now but my dhtml menu is not working. might be something to do with having 2 onloads now.

    Thanks anway


  •  

    Posting Permissions

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