PDA

View Full Version : Random index page?


Richard Adams
5-24-05, 09:36 AM
Hi everyone,

I'm not sure if this is possible and if it is, I'm wondering how I could do it.

On my index page, I want to have a central image. However, I have about five different colours that this image is in. Is it possible for a visitor to visit this page, then the next time they visit it, it's a different colour of the picture?

I hope the above make sense. Thanks in advance.

Richard.

B&T
5-24-05, 12:12 PM
This very simple JS will randomly pick one of the images to load. But since it is random, you still could get the same one twice in a row.
http://tips-scripts.com/?tip=image#tip

Skunkboy
5-24-05, 12:22 PM
As long as you don't set up the script when you're half dead (asleep) like I did, B&T's script is definately a nice way to go. I've got it setup with image, matching text, and the whole thing is hyperlinked.

Richard Adams
5-24-05, 12:35 PM
Ok guys, since your replies things have got a little more tricky...

My image is now split in two, in two table cells with one part being a background image. Is this still doable, B&T?

Richard.

EDIT: Or is there a simpler script that offers alternative index.html pages, then I just make one index page per image colour?

B&T
5-24-05, 01:05 PM
As long as you don't set up the script when you're half dead (asleep) like I did, B&T's script is definately a nice way to go. I've got it setup with image, matching text, and the whole thing is hyperlinked.
You are talking about the more complex version:
http://tips-scripts.com/?tip=random#tip
but he is looking for a simple image change, so this simple one will do:
http://tips-scripts.com/?tip=image#tip

B&T
5-24-05, 01:06 PM
Ok guys, since your replies things have got a little more tricky...

My image is now split in two, in two table cells with one part being a background image. Is this still doable, B&T?
Sure, you can use the same concept and coding technique with a background table cell image. IMHO this is a lot better than having different pages.

Richard Adams
5-24-05, 01:17 PM
Great,

So how would this work...e.g. where would I put the javascript coding? Here is my main source file:

<html>
<head>
<title>Welcome to Back 2 Magic, a site filled with free forums, high quality products and featured magic releases worldwide</title>
<meta name="keywords" content="2,magic,store,forums,back,high,quality,paypal,exte rnal,x,worldwide">
<meta name="description" content="Welcome to Back 2 Magic, a site filled with free forums, high quality products and featured magic releases worldwide">
<style type="text/css">
<!--
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
a:hover {text-decoration: underline; color:#000000}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" alink="#990000" vlink="#000000" link="#000000">
<table border="0" align="CENTER" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" bordercolordark="#FFFFFF">
<tr>

<td width="411" height="600" valign="top"><center><img src="/images/circle_black_left.jpg"></center></td>
<td width="159" height="600" BACKGROUND="/images/circle_black_right.jpg" valign="top"><br><br><br><br><b><font face="Verdana" size="3"><font color="#990000">| </font><a href="/store/">s t o r e</a><br><br><br><br><b><font face="Verdana" size="3"><font color="#990000">| </font><a href="/forums/"><font color="#FFFFFF">f</font> o r u m s</a><br><br><br><br><b><font face="Verdana" size="3"><font color="#990000">| </font><a href="/xternal/"><font color="#FF0000">x</font><font color="#FFFFFF"> - t e</font> r n a l</a><br><br><br><br><b><font face="Verdana" size="3"><font color="#990000">| </font><a href="/sitemap.html"><font color="#FFFFFF">s i t e m</font> a p</a><br><br><br><br><b><font face="Verdana" size="3"><font color="#990000">| </font><a href="/store/contact.html"><font color="#FFFFFF">c o n t</font> a c t</a></td>

</tr>
</table>
<br><br><font face="Verdana" size="1"><font color="#AAAAAA"><center>Welcome to Back 2 Magic, a site filled with free forums, high quality products and featured magic releases worldwide.</center></font>
</body>
</html>

The images I want to replace are:

circle_black_left.jpg and circle_black_right.jpg

for:

circle_red_left.jpg and circle_red_right.jpg

Thanks for your help thus far.

Richard.

B&T
5-24-05, 02:43 PM
I gather you are not that familiar with JavaScript. You replace those lines (or part of a line) that refer to the images with script lines. The document.write creates the output.

Since I think you should understand what is on your webpage, I suggest you try using the Tip just as it is on a test page and see how the random rotation works. Play with it, convert it to a simple table background, image and make sure it works the way you want, then move the code to your webpage.