Forum Moderators: mack
Can someone please help? My eyes are bleeding from searching.
The first is to have some Javascript code on your page that randomly picks one of six CSS stylesheets to use. You can probably find how to use Javascript to switch stylesheets with a Google search.
If you have only a couple of items to change, you could do that on the fly with Javascript, e.g.
<script type=text/javascript>
colors = ['blue','red','green','yellow','orange','brown'];
x=Math.floor(Math.random()*6);
document.bgColor=colors[6];
</script>
Another option is to use server-side scripting to deliver a random CSS stylesheet. For example, using PHP, your page could have:
<?
(logic for selecting one of six lines that ultimately prints something like)echo "<LINK rel=stylesheet type=text/css href=/css1.css>";
?>
If you really insist on using the redirect route, then you'd be looking at having some Javascript code that looks something like this:
<script type=text/javascript>
x=Math.floor(Math.random()*6)+1;
window.location="index"+x+".html";
</script>
But this seems like a really bad practice. It's not good practice to ever take users to a page that they can't actually use. It's better practice to keep the user on the page they went to, and then fix up that page to display the way you want it to.
[edited by: MichaelBluejay at 9:02 am (utc) on Sep. 11, 2007]
I just want to make it so that every visit or refresh pulls up one of those, randomly.
[edited by: engine at 9:42 am (utc) on Sep. 11, 2007]
[edit reason] See TOS [webmasterworld.com] [/edit]
But since I had a look at your site before the links were removed, I can see that none of the good suggestions I gave you will work, because your colors are generated by Flash. Most webmasters on this board don't like the use of Flash to generate all the content, because while Flash is very pretty, it's terrible for getting your site to rank well in the search engines. If that doesn't bother you, we can proceed on solving your issue. If it does bother you, then you'll need to consider re-doing your site without so much Flash.
The proper way to solve your issue if you want to keep the Flash is to have *Flash* pick the colors. Flash code is programming code, so just go to whoever developed your Flash for you, and tell them that you want it to pick one of six color schemes every time it loads. That's the proper way to do this.
I know you have your heart set on redirecting, but I promise you that's the wrong way to do it, as I mentioned in my first post. But if you really insist on doing it that way, then you can do it using a modified method I mentioned in that first post. I'll ask that you learn enough Javascript to do that yourself, rather than just handing you the complete code, because if you're going to go about this the wrong way, you should have the responsibility of writing that code yourself. :)
If you try to write your code and it doesn't work, then feel free to post about your troubles in the Javascript forum and people can help you there.
(1) Use your redirection idea -- and learn enough Javascript to be able to code it yourself. It shouldn't take more than an hour or two.
(2) Hire a Flash developer to modify the code of your template. This is a good route because then you have only one url, not seven.
(3) Rename your page to <index.cgi> or <index.php>, where the file is either a Perl or a PHP script that randomly loads one of your six color schemes. This is another method that lets you have one url, not seven.
(4) Re-do the site without using Flash. Then you can use Javascript to set the colors.
Good luck!