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

    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.

    <head>

    <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 + "')
    }
    </script>

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


    </head>

    <body onload="pickimage()">

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    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
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    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).

    Luck,
    CJSL
    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, 11:27 AM
  2. Replies: 8
    Last Post: 04-19-2009, 05:50 PM
  3. BackGround & ForeGround
    By hungleon88 in forum Advanced Java
    Replies: 3
    Last Post: 08-31-2008, 07:20 AM
  4. random numbers without random class`
    By carlos123 in forum New To Java
    Replies: 4
    Last Post: 01-17-2008, 10:44 PM
  5. Set the background in Java
    By barney in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07: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
  •