Results 1 to 3 of 3
  1. #1
    mchapple is offline Member
    Join Date
    Jan 2009
    Rep Power

    Default Random Div Background Images

    I know absolutely no java and I am trying to set random background images in my masthead. I have been searching and trying all day and can't figure this out. I've pasted some of my code below, can someone please tell me what I'm doing wrong and how to fix it.


    <title>WELCOME TO ONWA</title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <script language="javascript" type="text/javascript">
    var backgroundSrcs = new Array("banner1.png","banner2.png","banner3.png","b anner4.png","banner5.png","banner6.png","banner7.p ng")

    function pickimage()
    var bgimage=backgroundSrcs[(Math.round(Math.random()*(backgroundSrcs.length-1)))]

    document.getElementById("masthead").style.backgrou ndIimage = "url('" + bgimage + "')

    <link rel="stylesheet" type="text/css" title="CSS" href="styles/style3.css" media="screen" />


    <body onload="pickimage()">

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    JavaScript != Java

    You will do well to search out and post this in a JavaScript forum. Best of luck!

  3. #3
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Rep Power

    Default Javascript?

    Huh... that looks like Javascript... which is NOT Java and this is a Java forum for developers. Maybe somebody here knows the answer, but I would suggest that you try a Javascript forum (you'd probably have beter luck getting an answer to your question).

    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. How to Run a .exe in background???
    By jazz2k8 in forum New To Java
    Replies: 9
    Last Post: 01-21-2011, 12:27 PM
  2. Replies: 8
    Last Post: 04-19-2009, 06:50 PM
  3. BackGround & ForeGround
    By hungleon88 in forum Advanced Java
    Replies: 3
    Last Post: 08-31-2008, 08:20 AM
  4. random numbers without random class`
    By carlos123 in forum New To Java
    Replies: 4
    Last Post: 01-17-2008, 11:44 PM
  5. Set the background in Java
    By barney in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 08:13 AM

Posting Permissions

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