Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

54 users online



changing bg color on refresh

changing bg color on refresh

Currently viewing this thread: 1 (0 members and 1 guests)


Credo

Credo

Status: Offline!

changing bg color on refresh

Hey, I'm trying to figure out how to change background color on a page every refresh. Same sort of idea as spoono's site. The way the background design changes every time the page is re-loaded. can anyone point me in the right direction to a site, or a tutorial that explains how to do it?

thanks in advance everyone!
~C.

evan

evan

Neverside Newbie
Status: Offline!

Let's see if I can do this Tongue
This may or may not work. My knowledge of javascript isn't that great.

This goes in your header

Code:

<script type="text/javascript">
// List of colors. Add as many as you like
var bgcolors = new array( "#000000", "#ffffff", "#00ff00" )

document.bgcolor = bgcolors[Math.random( )]
</script>

Credo

Credo

Status: Offline!

Thanks alot! Smile

fredmv

fredmv

Status: Offline!

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<script type="text/javascript">
/*<![CDATA[*/
var colors = ["#ff0000", "#00ff00", "#0000ff"];

onload = function()
{
document.body.style.backgroundColor = colors[Math.floor( Math.random() * colors.length )];
}
/*]]>*/
</script>
</head>
<body>
<div></div>
</body>
</html>

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

evan

evan

Neverside Newbie
Status: Offline!

I was close! Tongue

fredmv

fredmv

Status: Offline!
Quote:

Originally posted by akdov
I was close!


Nice try! :grinning

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0082 seconds.