Web Analytics Made Easy -
StatCounter plz help me... - CodingForum

Announcement

Collapse
No announcement yet.

plz help me...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • plz help me...

    Hello!

    I m creating an application and in that i m having the login form which is being given an background image(.jpg). Now what i want is i m having a set of six different .jpg images and i want that everytime the user comes on the login page the background image should be changed or it should even be changed if the page is being refreshed. Help me out ...

    Thanx in advance,
    bhavin...

  • #2
    <script language="javascript">
    var bg = new Array("bg1.jpg","bg2.jpg","bg3.jpg","bg4.jpg","bg5.jpg","bg6.jpg,");
    function putBg(obj){
    index = Math.floor(Math.random()*(bg.length-1));
    this.background = bg[index];
    }
    </script>
    </head>
    <body onload="putBg(this)">
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      The solution u gave to me is not woking. And there is no error given but yes the background remains unchanged.

      Comment


      • #4
        try this:

        <script language="javascript">
        var bg = new Array("bg1.jpg","bg2.jpg","bg3.jpg","bg4.jpg","bg5.jpg","bg6.jpg,");
        function putBg(obj){
        index = Math.floor(Math.random()*(bg.length-1));
        obj.style.backgroundImage = bg[index];
        }
        </script>
        </head>
        <body onload="putBg(document.body)">

        if that doesn't work, then you may have to change the line in bold, so that it looks like this:

        obj.style.backgroundImage = "url(\"" + bg[index] + "\")";

        hope that helps
        bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

        i am a loser geek, crazy with an evil streak,
        yes i do believe there is a violent thing inside of me.

        Comment


        • #5
          Thanx joh6nn it is working very well. Thanx alot...

          Comment

          Working...
          X