Random div background

This is a discussion on "Random div background" within the JavaScript Forum section. This forum, and the thread "Random div background are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Mar 5th, 2008, 18:32
New Member
Join Date: Mar 2008
Location: Belfast
Age: 21
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Random div background

Hey all,

I have created a site using div's rather than tables and I want one of the divs to randomly change background as the user visits and refreshes the page. I found a site which offers something very close...
http://www.groan-zone.net/jscript/random.html

This works perfect but it changes the main background of the page. I can see the bit of the code which tells it to change the body background specifically and assume that this is the part I need to change but I don't know what to change it to to refer it to a div (the div id in question is header, if that helps explaining it). Does anyone have any ideas? It would be greatly appreciated.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Mar 5th, 2008, 20:11
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: Random div background

without looking you might need to create a 'class' and use that
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Mar 5th, 2008, 20:18
Reputable Member
Join Date: Jun 2007
Location: uk
Posts: 459
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Random div background

I am no expert, but something like this might work '(or not)'

HTML: Select all
document.write('<div id="header"' + image + '" text="white"</div>')
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Mar 5th, 2008, 20:26
New Member
Join Date: Mar 2008
Location: Belfast
Age: 21
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Random div background

dab24pat,
Thanks but I've tried a lot of trial-and-error approachs including what you laid out.

saltedm8,
Thanks as well, I thought I might have to make a class for it I just have to figure that part out lol

Here's the CSS code for the header if it's any help:
#header
{
padding:0.5em;
color:white;

margin-top:10px; margin-left:10px; margin-right:10px;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Mar 6th, 2008, 17:43
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: Random div background

to create a 'class' you need to do something like this

Code: Select all
<div class="myclass" id="header"></div>
and style the class with something like this

Code: Select all
.myclass { background:#00FF33; ETC... style
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)

Last edited by saltedm8; Mar 6th, 2008 at 17:46.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Apr 9th, 2008, 18:54
New Member
Join Date: Apr 2008
Location: Sacramento, cA
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Random div background

This will do what you're looking for: http://www.alistapart.com/articles/betterrotator
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for random bouncing ball bubberz Flash & Multimedia Forum 1 Oct 24th, 2007 21:35
Random .swf on refresh jtyoungs JavaScript Forum 2 Sep 19th, 2007 12:48
Issues with random background music elusified JavaScript Forum 0 Aug 28th, 2007 10:10
random benbramz Classic ASP 5 Jul 18th, 2005 05:01
Random records.. u2orange Databases 6 Mar 8th, 2004 09:31


All times are GMT. The time now is 03:42.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42