0

Hi,
So, I have a client that wants a new background image every time page is reloaded. I thought I have to script and thought I had it working but when I applied it to all my pages from a template I made in dreamweaver it doesn't work. It only works on the template. Any ideas....??? Oh, FYI I have no background css so things won't get confused. See code below.

<head>
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");
}

function MM_displayStatusMsg(msgStr) { //v1.0
status=msgStr;
document.MM_returnValue = true;
}
//-->
</script>
</head>


<body>
<script>

var randombgs=["../images/main_background.png", "../images/main_background2.png", "../images/main_background3.png", "../images/main_background4.png", "../images/main_background.png", "../images/main_background2.png", "../images/main_background3.png", "../images/main_background4.png"]

document.write('<body background="'+randombgs[Math.floor(Math.random()*randombgs.length)]+'" bgcolor="#FFFFFF">')
</script>
</body

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by SEOCoder
0

I don't know about your javascript, but if you know PHP you can use it in a CSS file and then randomly generate the background image there.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.